How to change git repository using android studio
Solution 1
Go to your project directory and delete hidding .git folder like shown below
you will be disconnected to git.
Solution 2
We can change the repository url. Just follow the steps.
In Android Studio Arctic Fox | 2020.3.1
- Right click on project folder
- From menu Choose “Git”
- Then chosse "Manage Remotes..."
- Now, select the existing "origin" and click on edit
- Enter your new URL and click OK
For Android Studio Older versions
- Right click on project folder
- From menu Choose “Git”
- Choose “Repository”
- Choose “Remotes…”
- Now you got the “Git Remotes” popup
- You can edit the existing url or remove the old url and then add new url.
- Click “OK”. that’s it. Now you are connected with new repo. But branches are not connected. Just follow few steps to complete.
- Try to pull the changes from repo “Git > Repository > Pull…”
- Now you got the “Pull Changes” popup. Click “Refresh” button.
- After successfully reconnected with repo then you can see the branches of new repo under “Branches to merge” box.
- Done. Now you are connected with new repo & branches.
Happy Coding :)
Solution 3
You can use SmartGit application and set your new git url at "Remote\Properties..." and then push button "Store".
Or you can go to "[project folder]\.git" and edit "config" file. Find line "url = https//[your current url]" and put your new url instead.
Solution 4
2021 method
Tested on Android Studio Arctic Fox | 2020.3.1
- Right click on project folder
- From menu Choose “Git”
- Then chosse "Manage Remotes..."
- Now, select the existing "origin" and click on edit
- Enter your new URL and click ok
JayD
interested fields : java, google, android, apple, git, mac os, movie, comics, music, etc...
Updated on September 11, 2021Comments
-
JayD over 2 years
I'm using git with android studio and I already sync other repository.
But I hope to change a git repository like github.
I think I need to disconnect already connected to the repository but I don't found this option.
To do that, How can I do?
-
JayD almost 9 yearsThank you. But Android Studio doesn't have this option?
-
Swapnil Kadam almost 5 yearsfor Mac users to access hidden .git folder user cmd+shift+.(dot) and same combination to hide them back.
-
jim about 4 yearsi never got the old repo to accept anything, (thats why I want a new repo to try and fix stuff going to github). Q: Do I skip the branch steps since I got nothing out yet??
-
Divakar Murugesh about 4 yearsI thought every repository have master branch by default. so we can choose that. I am not sure about this.
-
Alan Bastos over 2 yearsThis is the correct answer for new versions of android studio.