Search code examples
gitgit-remote

How to recover from a state where a remote cannot be fully deleted?


I have run git remote remove origin, but the remote origin doesn't get fully removed.

Now when I run git remote -v, it lists origin, but does not give any URL next to it.

All other git remote commands will tell me error: No such remote: 'origin'.

There is no mention of origin in .git/config.

I have tried re-adding an origin remote, then fetching from it, then removing it again. These commands are all successful but they leave me in the same state.

Any ideas how I can make git forget about this origin remote?

[Background: The repo uses git-lfs, and I regularly get smudge filter lfs failed errors when merging/rebasing from upstream (the main company repo), and the only workaround I have found is to delete all remotes, re-add upstream, fetch, then do the merge/rebase before adding back any additional remotes. This stubborn corrupt remote is preventing this process from working.]


Solution

  • This could be from the global ~/.gitconfig. Find it out with

    git config --get-regexp --global "remote\.*"
    

    or

    git config --list --show-origin | grep -Fw origin
    

    PS. Hm, hmm, --show-origin is about a different kind of "origin". :-)