How to remove a git remote

In the comments of my article How to use GitHub with Android Studio 1.x, Cynthia gets the following error:


can't add remote
fatal: remote origin already exists.
during execution git remote add origin

Unfortunately, it seems that Android Studio doesn’t offer any way to modify/add/remove git remotes from your repository. However you can still remove it by following the below steps. I am using Windows 8.1 but it should work on other operating systems (for Mac/Linux just replace command line with the console or terminal).

First, navigate to the root of your project in the file system, right click the background of the directory and select Git Bash:

Andorid Studio 1.x root project directory

This will bring up the git console. In the git console type the following command:


git remote rm origin

Git remove remote

The git remote will now be removed from the repository.

If you found this post helpful and you’re looking for more in-depth training, check out my ebook How to Use GitHub with Android Studio: A complete step-by-step guide to mastering the technology.

Cheers,
Mark

5 replies
  1. Abhilash
    Abhilash says:

    Hi there,
    Even i faced the same issue and followed your advice.Well now i am able to share on github again.But it is again creating an old repository which i had deleted a while ago.If i try to share again, i again get the error
    can’t add remote
    fatal: remote origin already exists.
    during execution git remote add github

    .Bottom line is an old repository of mine keeps recreating if i try to share some other project from android studio :(.
    Please help

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *