trejas
trejas

Reputation: 1031

How to delete a git remote that no longer exists

I am trying to do some remedial git clean-up work on a repository that was started a while back. When I run git branch -a I get the following output:

$ git branch -a
* master
staging
remotes/origin/master
remotes/origin/staging
remotes/pythonanywhere/master
remotes/pythonanywhere/staging
remotes/staging/staging

The remotes/staging/staging remote does not exist anymore. It does not show up in the list when running git remote -v.

This also seems to mean I cannot delete the remote.

get fetch -p, git remote prune staging also do not work.

Also the remote does not show up in the list of remotes when running git config --local -l

EDIT:

The suggested possible duplicate questions/answers did not work when trying to solve this issue. For some reason the remote was left as an orphan. See the accepted answer below for what worked.

Upvotes: 2

Views: 1186

Answers (2)

wmorrell
wmorrell

Reputation: 5337

As per the suggestion in the comments, this is what works:

git remote add <remote name> <url> 
git remote remove <remote name>

Seemed to clear out some dangling reference to the orphaned remote.

Upvotes: 1

mintychai
mintychai

Reputation: 311

Is this the same question you have?

git remote prune origin prunes tracking branches not on the remote.

Upvotes: 4

Related Questions