Search code examples
gitgit-remote

Git: How to remove secondary remote repo


I had set up a 2nd remote repository by running this command

git remote set-url origin --push --add <another remote>

When I do a git remote -v

origin  https://url1.com/a.git (fetch)
origin  https://url2.com/a.git (push)

How can I remove one of the remote repo?

Looking at git remote --help, I see that I can do

git remote remove origin, but would that remove both of them?

What's the best practice to have multiple remote URLs? Should I have set different branch names instead of having 2 origins?


Solution

  • Your situation has only one remote, origin. To change the push value of the remote, without adding a new value, use git remote set-url without --add. To be extra-explicit, you can also specify the URL that you want to replace:

    git remote set-url origin --push https://url1.com/a.git https://url2.com/a.git
    

    This replaces your updated url2 with your original url1.