user345280
user345280

Reputation: 1930

Remove old and add new git in android studio

I have tried to configure android studio with git and messed up.

How to completely remove old git that I could create new one?

Upvotes: 23

Views: 37131

Answers (10)

CNK
CNK

Reputation: 693

For me, the better solucion using Android Studio with Flutter projects was:

  • Create a new project in Android Studio
  • Close Android Studio
  • Outside from Android Studio, with Finder (Mac) copy from my old (corrupted) project the entire lib folder and the pubspec.yaml file to the new one, overwriting.
  • Enable Git in the new project from Android Studio again

Upvotes: 0

Vladimir Salguero
Vladimir Salguero

Reputation: 5947

You can remove GIT from your Android Studio Project in File → Settings → Version Control → In VCS select and Apply.

enter image description here

Then you can add it back in VSC Menu → Enable Version Control Integration → Select GIT → OK button.

enter image description here

Upvotes: 9

yoAlex5
yoAlex5

Reputation: 34195

Remove and add git

//progect_path is path where .git is located
cd <progect_path> 
rm -fr .git
git init

Upvotes: 0

A.Klapchuk
A.Klapchuk

Reputation: 70

In Android Studio terminal in your project dir: Windows:

rd /s /q ".git"

Linux/Mac:

rm -rf .git

Upvotes: 3

cooldesignpro
cooldesignpro

Reputation: 31

If you delete a git repository from github, you should also delete a folder name .git from your Android Studio root directory.

Then you have to close the project. And re-open it in Android Studio.

Then do these things: 1) VCS -> Enable Version Control Integration -> Git 2) In Project view in Android Studio, select the project root folder and right click on it. Then go to Git -> Add, after that Git -> Commit Directory, and then Git -> Repository -> Push .

Whenever you get prompts in this way, just click on appropriate options.

Upvotes: 2

Abhishek
Abhishek

Reputation: 1

  1. Remove the git folder in Project directory

  2. Run this command git init in Terminal

  3. Vcs=> Git=>remote and add new

  4. Paste the new git URL

  5. After, verify your GitHub credentials

Now new git attached to your project

Upvotes: 0

VojtaStruhar
VojtaStruhar

Reputation: 651

I find the top answer little bit too complicated, although fully functional. So here is maybe little bit easier to understand practice:

Assuming you already have project, and you want to change target (Bitbucket in my case) directory.

  • Go to project directory: cd Your/project/location
  • Find your current remote: git remote (its name will be probably origin)
  • Delete it: git remote remove yourOldRemoteName
  • Make sure you deleted the remote: git remote (should display nothing)
  • Create new remote: git remote add yourNewRemoteName repositoryUrl

(If you are using Bitbucket, your url will be something like https://[email protected]/your-company/yourRepository.git and you will find it by clicking Clone button in source folder of your repository or when creating the repository.)

Hope this will be useful!

Upvotes: 2

Nihas Nizar
Nihas Nizar

Reputation: 617

Just a simple way

Open the terminal in android studio.

git remote set-url origin <NEW GIT URL>

now the project url is changed from old link to new one. Then you can use >

git init

and upload your files. Happy coding :)

Upvotes: 8

neshkeev
neshkeev

Reputation: 6476

In order to drop the current git repository and create a new one you need to:

  • Go to the project's directory: cd PROJECT_DIRECTORY

  • Remove all the git specific files: rm -rf $(find . -name ".git*")

  • Initialize a new git repository: git init

This doesn't remove your project's files, only git configs

Upvotes: 43

Ben
Ben

Reputation: 1061

Delete the .git folder & .gitignore and start again.

Google for how to display hidden folders on windows to see the .git folder.

Upvotes: 3

Related Questions