Reputation: 20222
I've observed that my Git repository has two remotes for origin because when I run this:
git config --get-regexp 'remote\\.origin\\..*'
I get two results:
remote.origin.url https://user:password@my-repo:7990
remote.origin.url http://my-repo.com:7990/scm/my-project.git
However, I fail to delete either of them. For instance, if I try to delete the first one, like this:
git remote set-url --delete origin https://user:password@my-repo:7990
I get:
fatal: could not unset 'remote.origin.url'
Any idea why this error appears?
Upvotes: 9
Views: 11067
Reputation: 121
If it is a remote added with --push
option you have to use --push
option again to delete the remote like this:
git remote set-url --delete --push <remote_name> <remote_url_to_delete>
This will only delete the URL, not the remote.
I was having the same issue with a pushable remote added with --add --push
option like this:
git remote set-url --add --push <remote_name> <remote_url>
This is usually made to have diferent URLs to the same remote to push changes faster to diferent places.
If you would like to do that, after adding the URLs you just have to use:
git push <remote> <branch>
And it will push to every URL added to your remote
Upvotes: 3
Reputation: 24136
You can remove the remote origin
then add again.
$ git remote rm origin # remove a first remote
$ git remote -v
# if you see your second origin
$ git remote rm origin # remove the second origin
$ git remote add origin <repo-url> # add new origin
$ git remote -v # see all the remotes you have
Upvotes: 11