git - 清理旧的远程 git 分支

标签 git git-branch

我在两台不同的计算机(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/

相关文章:

git - 如何从当前版本和比最新版本更旧的版本之间的差异 View 编辑文件的当前版本?

git - 如何创建 Git 属性文件

linux - 创建文件 :///URI based on the file's directory (pwd) 的 Unix 命令

xcode - 无法推送已推送到 Bitbucket 的最近对 Github 的提交

git - 确定分支何时 merge 到另一个

git - 如何运行 git log 以仅查看特定分支的更改?

Git:禁用单个 git 用户的每个分支的读取访问权限?

git - 获取从远程分支到本地孤立分支的完整提交历史记录

git - "Layering"git 存储库

Git merge 和修复带有两个分支的混合空间和制表符