git 已删除的远程分支仍列在 TortoiseGit 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19928808/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:21:05  来源:igfitidea点击:

Deleted remote branches still listed in TortoiseGit

gittortoisegit

提问by Mr. Boy

I have noticed TortoiseGit seems to contain every feature branch I ever created, both in drop-downs for local branches AND remote, even though many of the remote branches were deleted after being merged into master.

我注意到 TortoiseGit 似乎包含我曾经创建的每个功能分支,无论是在本地分支还是远程的下拉列表中,尽管许多远程分支在合并到 master 后被删除。

Is there a way in TortoiseGit to synhronise which branches are listed to those actually existing?

TortoiseGit 有没有办法将列出的分支与实际存在的分支同步?

And a slight tangent... in terms of Git itself is a local version of a branch considered totally decoupled from the remote? i.e. there is no reason why deleting the remote version shouldautomatically mean the local one is deleted?

有点切线......就Git本身而言,是一个被认为与远程完全分离的分支的本地版本?即没有理由删除远程版本应该自动意味着删除本地版本?

回答by VonC

You can do, as mentioned in issue 1139, a Fetch with prune.
Or remove Remote Branch from list in Pull issue 2765.

issue 1139所述,您可以使用 prune进行Fetch
或者从 Pull issue 2765 的列表中删除远程分支。

That will clean-up any remote branches still locally referenced, while they are already deleted in the upstream repo.

这将清理仍然在本地引用的任何远程分支,而它们已经在上游 repo中被删除。

http://wiki.typo3.org/wiki/images/1/18/Tortoisegit_fetch.gif

http://wiki.typo3.org/wiki/images/1/18/Tortoisegit_fetch.gif

in terms of Git itself is a local version of a branch considered totally decoupled from the remote?

就 Git 本身而言,是一个被认为与远程完全分离的分支的本地版本?

It can be.
If a branch has an remote tracking branch associated to it, git branch -vvcan show it.

有可能。
如果一个分支有一个与之关联的远程跟踪分支,git branch -vv可以显示它

But removing said remote tracking branch has no bearing on the local branch.

但是删除所述远程跟踪分支对本地分支没有影响。

i.e. there is no reason why deleting the remote version should automatically mean the local one is deleted?

即没有理由删除远程版本应该自动意味着删除本地版本?

Sure: you pushed by mistake a 'test' branch:

当然:你错误地推了一个“ test”分支:

  • you want to delete it on the remote repo
  • but you very much want to keep it on your local repo to pursue some local tests you have no intention of pushing.
  • 你想在远程仓库上删除它
  • 但是您非常希望将它保留在您的本地存储库中以进行一些您无意推动的本地测试。

回答by Jokester

To the last question, I believe that's an aspect of being "distributed". While local repo and remote repo may share contents to each other, they exist independently.

对于最后一个问题,我认为这是“分布式”的一个方面。虽然本地 repo 和远程 repo 可以相互共享内容,但它们独立存在。

In practice this design may prevent trouble. If fetchcompletely reflects changes of "local branch in remote repo" to "remote branch in local repo", and someone removed a branch in remote repo, we will lose one local pointer of some commit (maybe the last one).

在实践中,这种设计可以防止麻烦。如果fetch将“远程仓库中的本地分支”的更改完全反映为“本地仓库中的远程分支”,并且有人删除了远程仓库中的一个分支,我们将丢失某个提交(可能是最后一个)的一个本地指针。

回答by coz

TortoiseGit synchronizing the branches listed to those actually existing is a feature request.

TortoiseGit 将列出的分支与实际存在的分支同步是一个功能请求。

At least you can use Shift + Delete to remove the item you don't want: Open the dialog, open the combobox for the list of branches, in the expanded list position the mouse pointer on one entry and shift+delete it.

至少你可以使用 Shift + Delete 删除你不想要的项目:打开对话框,打开分支列表的组合框,在展开的列表中将鼠标指针放在一个条目上,然后 shift+delete 它。

The items in Remote Branch drop list are cached by TortoiseGit. Max size is 25.

远程分支下拉列表中的项目由 TortoiseGit 缓存。最大尺寸为 25。

Next time you want to pull, the suggestion list will contain only the name of the current branch.

下次要拉取时,建议列表将仅包含当前分支的名称。