清理旧的远程git分支 [英] cleaning up old remote git branches

查看:111
本文介绍了清理旧的远程git分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我从两台不同的计算机(A和B)工作,并将常用的git远程存储在收存箱目录中。



假设我有两个分支master和devel。现在,在计算机A上,我删除分支开发 - 无论是本地还是远程 - 如下所示:

p>

  git push origin:heads / devel 

git branch -d devel
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 上删除了 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 get

master
origin/HEAD
origin/master

I now go to computer B. Do git fetch. I can remove the local devel branch by

git 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 on origin, 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 your git statement to see the result of running it without actually running it.

这篇关于清理旧的远程git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆