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?
The git remote remove command removes a remote from a local repository. You can use the shorter git remote rm command too. The syntax for this command is: git remote rm <remote-url>. If you remove a remote accidentally, you will need to add it back manually using the git remote add command.
You can view that origin with the command git remote -v, which will list the URL of the remote repo.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With