Search code examples
gitgit-remote

`git remote` lists 'origin' after removal


How is the following output possible? git remote is still showing 'origin', after it has been removed:

$ git remote -v
origin

$ git remote remove origin
error: No such remote: 'origin'

I can add another 'origin', and remove it, but it is still listed afterward:

$ git remote add origin ../  # some arbitrary path

$ git remote -v
origin  ../ (fetch)
origin  ../ (push)

$ git remote remove origin

$ git remote -v
origin

The .git/config file is

[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
  • This repo was created by cloning a local repo, and then removing 'origin'.
  • I am on Windows (git version 2.46.0.windows.1).

EDIT

As Michele De Falco guessed, I have something in my config:

$ git config --global --list | grep origin
remote.origin.prune=true

After removing it, the output of git remote -v is empty, as expected.


Solution

  • Run git config --global --list and git config --system --list, if origin is there then run git config --global --unset remote.origin.url