0

Seems like I accidentally added a few links to my local repo. So when I'm trying to push my code using git push -u origin 'branch'to the remote I get this error:

warning: remote.origin.url got a multiple values
fatal: could not set «remote.origin.url» at «https://Name:MyToken@github.com/Name/Repo.git»

So, I thought the problem was related to git auth tokens, but when I run git remote show origin. It turned out I have multiple remote origin links for push:

**Don't pay attention at other blocks, everything that you need at this picture is already translated

* external repo origin
  URL to extract: https://Name:MyToken@github.com/Name/Repo.git
    URL to send: https://Name:MyToken@github.com/LovePelmeni/Repo.git
    URL to send : git
  HEAD ветка: main
  Внешние ветки:
    main              отслеживается
    order_tracker     отслеживается
    service_discovery новая (следующее извлечение сохранит ее в remotes/origin)
  Локальные ветки, настроенные для «git pull»:
    main          будет слита с внешней веткой main
    order_tracker будет слита с внешней веткой order_tracker
  Локальные ссылки, настроенные для «git push»:
    main          будет отправлена в main          (уже актуальна)
    order_tracker будет отправлена в order_tracker (локальная ветка устарела)

So, I the question is how can I delete the remote origin link for push called git?

CraZyCoDer
  • 367
  • 1
  • 2
  • 16
  • Does this answer your question? [How to change the URI (URL) for a remote Git repository?](https://stackoverflow.com/questions/2432764/how-to-change-the-uri-url-for-a-remote-git-repository) – SwissCodeMen Jun 30 '22 at 21:02
  • If you want to set multiple values for `remote.origin.url` and/or `remote.origin.pushurl`, this is allowed; `git config --add` will set that up, for instance. I personally think it's a bad idea in general. It's possible to use `git config` from the command line to clean these up but I find it easier to use `git config --edit` or `vim .git/config` directly. – torek Jul 01 '22 at 04:12
  • I'm not sure how *you* got them set to multiple values, but if you're comfortable with editing plain-text files in vim or whatever editor you use, that's how I'd fix it myself. If not, you can use `git config --unset-all remote.origin.pushurl` to remove all the `pushurl` settings, for instance. Then `git remote set-url --push origin ` will set a single new separate push URL. – torek Jul 01 '22 at 04:15
  • @torek, I've seen the second approach, sounds great, but not really sure. Will it drop all of my commits I've made in the local branch after removing all of the origin urls and I need to make some backups? – CraZyCoDer Jul 01 '22 at 11:43
  • @SwissCodeMen, unfortunately not( – CraZyCoDer Jul 01 '22 at 11:44
  • Fussing with the `remote.*` entities in your editor will never affect *any* commits. Clearing out a remote entirely (`git remote rm`) clears out the corresponding remote-tracking names, which remember hash IDs of commits that *you didn't make*, and in some cases you could have those commits vanish, but commits *you made* should be found via your branch names, which will keep them safe. Using `set-url` never drops anything *yet*, it's only a later `git fetch` (if you've updated the fetch URL) that could drop "remote commits" (for want of a better phrase). – torek Jul 01 '22 at 13:39
  • @torek, Well, Looks Like I've finally solved the issue, thanks for your reply:) – CraZyCoDer Jul 01 '22 at 16:38

0 Answers0