How to change git repository using android studio

33,538

Solution 1

Go to your project directory and delete hidding .git folder like shown below

you will be disconnected to git.

enter image description here

Solution 2

We can change the repository url. Just follow the steps.

In Android Studio Arctic Fox | 2020.3.1

  1. Right click on project folder
  2. From menu Choose “Git”
  3. Then chosse "Manage Remotes..."
  4. Now, select the existing "origin" and click on edit
  5. Enter your new URL and click OK

For Android Studio Older versions

  1. Right click on project folder
  2. From menu Choose “Git
  3. Choose “Repository
  4. Choose “Remotes…”

Git > Repository > Remotes...

  1. Now you got the “Git Remotes” popup

Git Remotes

  1. You can edit the existing url or remove the old url and then add new url.
  2. Click “OK”. that’s it. Now you are connected with new repo. But branches are not connected. Just follow few steps to complete.
  3. Try to pull the changes from repo “Git > Repository > Pull…
  4. Now you got the “Pull Changes” popup. Click “Refresh” button.

Pull Changes

  1. After successfully reconnected with repo then you can see the branches of new repo under “Branches to merge” box.

Branches to merge

  1. 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

  1. Right click on project folder
  2. From menu Choose “Git”
  3. Then chosse "Manage Remotes..."
  4. Now, select the existing "origin" and click on edit
  5. Enter your new URL and click ok
Share:
33,538
JayD
Author by

JayD

interested fields : java, google, android, apple, git, mac os, movie, comics, music, etc...

Updated on September 11, 2021

Comments

  • JayD
    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
    JayD almost 9 years
    Thank you. But Android Studio doesn't have this option?
  • Swapnil Kadam
    Swapnil Kadam almost 5 years
    for Mac users to access hidden .git folder user cmd+shift+.(dot) and same combination to hide them back.
  • jim
    jim about 4 years
    i 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
    Divakar Murugesh about 4 years
    I thought every repository have master branch by default. so we can choose that. I am not sure about this.
  • Alan Bastos
    Alan Bastos over 2 years
    This is the correct answer for new versions of android studio.