当我运行命令git branch -a
时,我看到一个与不再存在的遥控器关联的分支列表。
例如:
remotes/does-not-exist/branch1
remotes/does-not-exist/branch2
remotes/origin/dev
remotes/origin/feature3
我想从上面的列表中删除与does-not-exist
相关联的分支。但是,如果我运行命令git remote prune does-not-exist
,我会收到以下错误
conq: repository does not exist.
fatal: Could not read from remote repository.
如何删除与does-not-exist
关联的分支?我应该删除.git/refs/remotes/
下的文件夹吗?
答案 0 :(得分:1)
您应该删除远程,而不是分支。这样,分支也将被删除。 git remote remove does-not-exist
。
答案 1 :(得分:1)
要删除远程分支,我运行git push origin --delete <branch>
。因此,在您的情况下,您可以运行以下内容:
git push does-not-exist --delete branch1
git push does-not-exist --delete branch2
我希望这会有所帮助。
答案 2 :(得分:1)
我使用 GitLab 网页将一个分支合并到 master。
在我的本地 shell 中,分支仍然存在
git branch -a
* 9-deploy
master
remotes/origin/9-deploy
remotes/origin/HEAD -> origin/master
remotes/origin/master
删除本地分支
git branch -d 9-deploy
删除对远程分支的引用
git fetch -p
使用以下 reference 查找命令