If you’ve worked with git repos for a while you will no doubt have come across a message mentioning “origin” or a “remote“. You may well have needed to add a remote to a git repo, but what if you need to remove a remote from your repository? I’ll explain how to git remove remote origin on the command line, and how to see a list of all the remotes.
If you’re not sure what a remote is, or what I mean by origin, then read my previous post about adding a git remote as I explain a little more about each in there. I’ve also written a post about what to do if you get a message saying something like “fatal: No such remote ‘origin’”.
View a list of remotes
First of all lets start by viewing a list of the remotes for the repo. To see a list of remotes for the repo, use the git remote -v
command.
Consider this scenario shown in the following image where I had accidentally set up two remotes, one called ORIGIN and called origin (bearing in mind that git is case sensitive).
Remove a remote from a git repository
I want to remove the remote that is lowercase ‘origin‘ version so I would use the following command :
git remote remove origin
You can see from the next image the result is correct, and we are now left with one remote in our git repository called ORIGIN.
Remember that git remove remote origin may not quite be what you’re looking for. If the remote you wanted to remove is called ‘azure‘, for example, then you’d want to use this command :
git remove remote azure
FAQS
You remove a remote by using:git remote remove ORIGIN