【问题标题】:Removed remote. But remote branch still shows移除了遥控器。但远程分支仍然显示
【发布时间】:2017-08-20 20:56:45
【问题描述】:

我添加了一个遥控器,所以我可以检查同事的代码。

$ git remote add coworker git@ourgitserver.local:...
$ git fetch coworker
$ git checkout coworker/theirbranch
$ git checkout -b mycopy

代码看起来不错。所以我做了一些清理工作:

$ git checkout master
$ git remote remove coworker
$ git branch -D mycopy

但他们的远程分支仍然出现:

$ git branch -a
remotes/coworker/theirbranch

我已经完成了git fetch -p --allgit gc --prune=now,但它们什么也没做。

我不能git branch -D coworker/theirbranch 因为遥控器不存在。我也不能git fetch -p coworker,因为那个遥控器不存在。

有什么想法吗?

【问题讨论】:

  • 为什么在清理树枝之前拆掉了遥控器?
  • 我认为这无关紧要。您不认为通过删除远程,对远程分支的引用会消失吗?

标签: git git-branch git-remote


【解决方案1】:

git remote remove coworker应该已经删除了相应的远程跟踪分支,并且在我运行的快速测试中确实如此,所以我不确定这里出了什么问题。

不过,要手动清理,您可以在每个剩余的远程跟踪分支上运行 git branch -d -r(注意两个标志):

git branch -d -r coworker/theirbranch

【讨论】:

  • 谢谢。 -r 标志成功了。达到最短时间后,我将标记为已接受。
猜你喜欢
  • 2019-05-18
  • 1970-01-01
  • 2016-06-28
  • 2021-04-15
  • 1970-01-01
  • 2011-07-02
  • 1970-01-01
  • 2016-11-08
相关资源
最近更新 更多