简体   繁体   English

EGit:修剪远程回购中已删除的远程跟踪分支

[英]EGit: Pruning Remote Tracking Branches that have been Deleted on the Remote Repo

I'm using EGit (for Eclipse) with a team of devs. 我正在与开发团队一起使用EGit(用于Eclipse)。 We have been creating a lot of feature and fix branches for new work, and then merging them into our release branches when they are completed. 我们已经为新工作创建了许多featurefix分支,然后在完成后将它们合并到我们的release分支中。 Right after they are merged into the correct release branch, these temporary branches are usually deleted to keep our remote repo clean. 在它们合并到正确的release分支之后,通常会删除这些临时分支以保持远程仓库清理。

I'm noticing that when these branches get deleted, I will fetch from our remote repo, but EGit doesn't remove them from my remote tracking view. 我注意到当这些分支被删除时,我将从我们的远程仓库中取出,但是EGit不会从我的远程跟踪视图中删除它们。 My remote tracking view will still show deleted branches that are no longer on the remote repo (and there is no indication that they have been deleted). 我的远程跟踪视图仍将显示已删除的分支,这些分支不再位于远程仓库上(并且没有迹象表明它们已被删除)。 The only way (I have found) to have my remote tracking view reflect the actual repo is to delete all of my remote tracking branches manually (highlight and delete), and then fetch them again. 我的远程跟踪视图反映实际仓库的唯一方法(我发现)是手动删除所有远程跟踪分支(突出显示和删除),然后再次获取它们。 This seems very roundabout, especially since you can prune remote branches via command line, like this: 这似乎非常迂回,特别是因为您可以通过命令行修剪远程分支,如下所示:

git remote prune origin

Basically, what I would like to know is if there is a way to configure/make EGit perform this pruning when remote tracking branches change (after I fetch). 基本上,我想知道的是,如果有一种方法可以配置/使EGit在远程跟踪分支发生变化时执行此修剪(在我获取之后)。 Here is my current fetch configuration on my origin remote: 这是我origin远程上的当前提取配置:

在此输入图像描述

Update March 2014: As mentioned by cheshire 's answer , EGit 3.3 added that prune feature. 更新2014年3月:正如cheshire回答所提到的, EGit 3.3补充说了修剪功能。

You can see said feature introduced in this Gerrit code review in JGit (and tested here ) 您可以在JGit中 查看Gerrit代码审查中引入的所述功能(并在此处进行测试

The entry fetch.prune mentioned in git config can be added to your Egit configuration: git config提到的条目fetch.prune可以添加到您的Egit配置中:

https://wiki.eclipse.org/images/f/f8/RepositoryConfigurationSettings.png


Original answer (March 2013) 原始答案(2013年3月)

EGit perform this pruning when remote tracking branches change (after I fetch). 当远程跟踪分支发生变化(我获取后)时,EGit执行此修剪。

Not that I know of. 从来没听说过。

More generally, perform any action after each fetch on the client side is not possible with hooks. 更一般地,在使用挂钩无法在客户端进行每次提取之后执行任何操作。
It has been requested , and was at one point implemented on the server side only: hook post-upload (run after a fetch), but removed, for security reason in a multi-user environment. 它已被请求 ,并且仅在服务器端实现了一点: 钩子post-upload (在获取后运行),但出于安全原因在多用户环境中被删除。

The recent EGit 3.3 release introduced prune support. 最近的EGit 3.3版本引入了修剪支持。

You can add a fetch.prune or a remote.<yourremotename>.prune key to the gitconfig and set it to true . 您可以将fetch.pruneremote.<yourremotename>.prune密钥添加到gitconfig并将其设置为true When you fetch with EGit, this will automatically prune branches that are deleted on the central repository. 当您使用EGit进行提取时,这将自动修剪在中央存储库中删除的分支。

Setting fetch.prune = true in the git-Settings solves the problem. 在git-Settings中设置fetch.prune = true可以解决问题。 If you do it in the Repository Settings, you can differ this setting for each repository. 如果在“存储库设置”中执行此操作,则可以为每个存储库区分此设置。 If you want to use this setting for each repository, you better put fetch.prune = true in the User Settings. 如果要对每个存储库使用此设置,最好在用户设置中输入fetch.prune = true。 So you don't have to repeat it for each repository. 因此,您不必为每个存储库重复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM