How to remove remote origin from a Git repository
Solution 1
Instead of removing and re-adding, you can do this:
git remote set-url origin git://new.url.here
See this question: How to change the URI (URL) for a remote Git repository?
To remove remote use this:
git remote remove origin
Solution 2
If you insist on deleting it:
git remote remove origin
Or if you have Git version 1.7.10 or older
git remote rm origin
But kahowell's answer is better.
Solution 3
To remove a remote:
git remote remove origin
To add a remote:
git remote add origin yourRemoteUrl
and finally
git push -u origin master
Solution 4
you can try this out,if you want to remove origin and then add it:
git remote remove origin
then:
git remote add origin http://your_url_here
Solution 5
I don't have enough reputation to comment answer of @user1615903, so add this as answer: "git remote remove" does not exist, should use "rm" instead of "remove". So the correct way is:
git remote rm origin

Om3ga
Updated on July 08, 2022Comments
-
Om3ga 6 months
I just did
git init
to initialize my folder as Git repository and then added a remote repository usinggit remote add origin URL
. Now I want to remove thisgit remote add origin
and add a new repositorygit remote add origin new-URL
. How can I do it? -
1615903 almost 9 years
remove
was added in 1.7.12. I have updated my answer. -
baash05 over 8 yearsThis is the actual answer to the question "how to remove remote origin from git repo".
-
kahowell about 8 years@acannon828, the protocol necessary depends on how you're connecting to git. The example provided assumes you are using the git protocol. The git book explains various protocols supported by git.
-
Ian Lewis about 8 yearsThis is the correct answer, there is some confusion caused by the phrasing of the title and the question itself.
-
Recomer almost 7 yearsIf you use Bitbucket instead of github you will delete the first "git://" part and directly write [email protected]:yourusername/reponame.git and of course change the place holders : "yourusername" and "reponame" with yours.
-
Michael about 5 yearsWhat if I have multiple URLs associated with origin, but only want to remove one of them?
-
1615903 about 5 years@Michael what exactly do you mean by "multiple URLs associated with origin"? How is the remote configured?
-
Samuel Aiala Ferreira about 4 yearsworked like a charm for me. It's not the prettiest way of doing it, but the git remote rm was not working ... and the suggestion at the github page didn't work either. Thanks
-
RobMac over 3 yearsbut then you loose all the history, right? in that case, why not pull in the code from the other/new repository?
-
Amrit Shrestha almost 3 yearsyes, it does remove the whole history. @Yasin should add some kind of warning with the answer.
-
Marko over 1 yearYeah, good solution if you want to also get rid of remote history, otherwise stick to other answers :)
-
Linguistics 12 monthsThis is not the correct answer, the correct answer is: git remote set-url origin new.url.here. Having git:// will just cause a fatal error. Not sure why this was in the answer.
-
serup 11 monthsI do not recommend doing this, if you want to maintain the commit history
-
Ekanem Eno 11 months@Michael You can achieve that using
git remote remove <name>
wherename
is the repo name, not the full URL -
Timo 10 months
rm
ingit remote rm
works in every git version I think, not just in old ones <2. -
cristiandatum 8 monthsjust make sure to keep checking your current remote repository address using "git remote -v" otherwise you might end up removing the wrong remote repository.