我在两台不同的计算机(A 和 B)上工作,并在 dropbox 目录中存储一个通用的 git 远程服务器。
假设我有两个分支,master 和 devel。两者都在跟踪他们的远程对应方 origin/master 和 origin/devel。
现在在计算机 A 上,我删除本地和远程的分支 devel。
git push origin :heads/devel
git branch -d devel
在计算机 A 上运行 git branch -a
,我得到以下分支列表。
- 大师
- 来源/HEAD
- 来源/主人
在计算机B上运行git fetch
,我可以用git branch -d devel
删除本地的devel分支,但是我不能删除远程的devel分支。
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
git branch -a
仍然在远程分支中列出 origin/devel。
如何清理计算机 B 的远程分支?
最佳答案
首先,在机器B上git branch -a
的结果是什么?
其次,你已经在origin
上删除了heads/devel
,所以你不能从机器B上删除它。
尝试
git branch -r -d origin/devel
或
git remote prune origin
或
git fetch origin --prune
并随意将 --dry-run
添加到 git
语句的末尾,以查看运行它的结果而不实际运行它。
git remote prune
的文档和 git branch
.
关于git - 清理旧的远程 git 分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3184555/