git - 移除了 Remote 。但远程分支仍然显示

标签 git git-branch git-remote

我添加了一个 Remote ,这样我就可以查看同事的代码。

$ git remote add coworker <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d7a74695d72686f7a74696e786f6b786f3371727e7c71" rel="noreferrer noopener nofollow">[email protected]</a>:...
$ 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 --all , git gc --prune=now而那些却什么也没做。

我做不到 git branch -D coworker/theirbranch因为 Remote 不存在。我也不能git fetch -p coworker因为那个 Remote 不存在。

有什么想法吗?

最佳答案

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

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

git branch -d -r coworker/theirbranch

关于git - 移除了 Remote 。但远程分支仍然显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43058470/

相关文章:

git - gerrit:推:先前提交和新提交之间没有变化。无法提取更改

svn - git svn : Delta source ended unexpectedly

git clone 从本地到远程

Git,如何让我的主镜像我的开发分支?

Git 从现有的远程分支添加一个工作树

git remote prune – 显示的修剪分支没有我预期的那么多

git - 为什么 "git log -‌- foo"对删除的文件 foo 不起作用?

git - 从现有的 Git 分支创建 SVN 分支

git - 当我已经有多个分支时应该如何添加新文件

git - 如何在不克隆/ checkout 的情况下获取存储库上标签之间的 git diff