question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Remote 'origin' already exists when it does not

See original GitHub issue

Does this issue occur when all extensions are disabled?: n/a Needs Git extension

  • VS Code Version: 1.69.0
  • OS Version: Windows 11 - Version 10.0.22000 Build 22000

Steps to Reproduce:

  1. Initalise a new repository
  2. Open git repo in sourcecode panel
  3. Remote -> Add Remote
  4. use origin as the remote name
  5. Error Remote ā€˜originā€™ already exists
  6. Confirm origin doesnā€™t exist git remote get-url --all origin -> error: No such remote 'origin'
  7. Use terminal to add remote git remote add origin <url>

You can then remove the origin remote using the Remote -> Remove Remote, and then try adding it using the UI and it still fails.

image

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
flipkickmediacommented, Dec 20, 2022

The worst part about that was it opening nanoā€¦vim till I die.

Ok so yes there is config defined, but this config is required to prune from origin when I fetch. This is another issue with VSCode, it ignores this config and doesnā€™t prune but that aside (Ill open another ticket for that) this config is needed.

Iā€™d suggest reworking the handling of remotes, and only when there is a URL should you complain about it existing.

git config --system -e
<Returns nothing>

git config --global -e

[user]
        name = Tom Shaw
        email = tom@flipkick.media
[credential]
        helper = manager-core
[pull]
        rebase = false
[remote "origin"]
        prune = true
[core]
        fileMode = true
[url "ssh://git@git.flipkick.media"]
        insteadOf = https://git.flipkick.media
0reactions
lszomorucommented, Dec 20, 2022

@flipkickmedia, thanks for the running the tests and for providing the additional information. Based on the provided data, it does look like VS Code correctly removes the ā€œremoteā€ section from the repositoryā€™s git config file. Having said that I just checked and if we cannot find any remotes in the repositoryā€™s git config file, we will always fallback to the output of git remote -v.

I believe that what we have to understand is why git remote -v returns a remote even though all remotes have been deleted. The only think that I can think of is that somehow either the system or the global git config has a ā€œoriginā€ remote defined and that is what is being returns by the git remote -v command. Could you please run these commands and see if the config files contain the ā€œoriginā€ remote:

  • git config --system -e
  • git config --global -e
Read more comments on GitHub >

github_iconTop Results From Across the Web

Remote Origin Already Exists Error: How To Fix It | CloudBees
1. Remove the Existing Remote. The first scenario we'll cover is the one in which there's already a remote called origin, but it's...
Read more >
How to fix 'fatal: remote origin already exists' Git error - Komodor
fatal : remote origin already exists is a common Git error that occurs when you clone a repository from GitHub, or an external...
Read more >
Remote origin already exists on 'git push' to a new repository
Remote origin already exists on 'git push' to a new repository Ā· Give the output of the command $> git remote -v show...
Read more >
How to Fix Git Error "Fatal: remote origin already exists" - Datree
The error `fatal: remote origin already exists` is caused when you attempt to create a link to a remote repository called ā€œoriginā€ when...
Read more >
How to Deal with fatal: remote origin already exists Error
Another reason is trying to change the URL of the ā€œoriginā€ remote repository using the git remote add command. The remote add command...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found