Git listing non-existent remotes

别等时光非礼了梦想. 提交于 2019-12-19 07:04:11

问题


I recently made some changes to my remote repos in my Git repo config file. I renamed the remote names, changing my origin to another remote repo and renaming my old origin.

For example, I had this previously:

[remote "origin"]
   url =  blah blah

[remote "future"]
   url = blah blah

I went in and changed them so they look like this:

# formerly the origin
[remote "old-origin"]

# formerly the future repo
[remote "origin']

But now, when I type git branch -a, I am seeing branches listed from the old 'future' remote:

remotes/origin/HEAD
remotes/origin/branch1
remotes/origin/branch2
remotes/future/branch1
remotes/future/branch2
remotes/old-origin/master
remotes/old-origin/branch3

I ran a prune as well as a fetch, etc. but that list just won't be updated. I did a search on my config file for 'future' and nothing turns up. Are there any commands I can run to refresh this list and stop looking at that nonexistent remote?


回答1:


You used to have a remote named future, and you don't now.

Hence, git remote whatever future can't help, because there is no remote named future. (Normally git remote update -p or git remote prune, as in the comments above, would let you get rid of these.)

The simplest option would seem to be to delete them manually:

git update-ref -d refs/remotes/future/branch1
git update-ref -d refs/remotes/future/branch2

(or rm -r .git/refs/remotes/future and/or edit .git/packed-refs, depending on whether these refs have gotten packed).

[Incidentally, I'd also run git config -e (or vi .git/config which is what I usually really do :-) ) and make sure there are no other left-over references to the future remote.]



来源:https://stackoverflow.com/questions/19298154/git-listing-non-existent-remotes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!