清理旧的远程git分支 [英] cleaning up old remote git branches
问题描述
我从两台不同的计算机(A和B)工作,并将常用的git远程存储在收存箱目录中。
假设我有两个分支master和devel。现在,在计算机A上,我删除分支开发 - 无论是本地还是远程 - 如下所示:
p> git push origin:heads / devel
git branch -d devel
$ c现在如果我在计算机A上执行 git branch -a
,我得到了
p>
master
origin / HEAD
origin / master
我现在进入计算机B.执行 git fetch
。我可以通过
git branch -d devel
来移除本地devel分支 pre>
但我无法移除远程devel分支。
git push origin:heads / devel
错误:无法推送到不合格的目的地:heads / proxy3d
目标refspec既不匹配远程的现有ref,也不以
开头refs /,并且我们无法根据源参考猜测前缀。
致命:远程端意外挂起
执行
git分支-a
仍然列出远程分支中的origin / devel。
如何清理机器B的devel远程入口?
解决方案首先,机器B上的
git branch -a
的结果是什么?第二,你已经在origin $ c $>上删除了
heads / devel
c>,所以这就是为什么你不能从机器B删除它。
尝试
git branch -r -d origin / devel
或
git remote prune origin
或
git fetch origin --prune
并随意在
git $>结尾添加
- dry-run
c $ c>语句来查看运行结果而不实际运行它。Here is my git workflow.
I work from two different computers (A and B) and store a common git remote in dropbox directory.
Let's say I have two branches master and devel. Both are tracking their remote counterparts origin/master and origin/devel.
Now while on computer A, I delete branch devel - both local and remote - as follows:
git push origin :heads/devel git branch -d devel
Now if I do
git branch -a
on computer A, I getmaster origin/HEAD origin/master
I now go to computer B. Do
git fetch
. I can remove the local devel branch bygit branch -d devel
But I can't remove the remote devel branch.
git push origin :heads/devel error: unable to push to unqualified destination: heads/proxy3d The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref. fatal: The remote end hung up unexpectedly
Doing
git branch -a
still lists origin/devel in remote branches.How can I clean up the remote entry of devel from machine B?
解决方案First, what is the result of
git branch -a
on machine B?Second, you have already deleted
heads/devel
onorigin
, so that's why you can't delete it from machine B.Try
git branch -r -d origin/devel
or
git remote prune origin
or
git fetch origin --prune
and feel free to add
--dry-run
to the end of yourgit
statement to see the result of running it without actually running it.这篇关于清理旧的远程git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!