git EGit:修剪远程仓库上已删除的远程跟踪分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15210929/
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
EGit: Pruning Remote Tracking Branches that have been Deleted on the Remote Repo
提问by Steven Byle
I'm using EGit (for Eclipse) with a team of devs. 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. Right after they are merged into the correct release
branch, these temporary branches are usually deleted to keep our remote repo clean.
我正在与一组开发人员一起使用 EGit(用于 Eclipse)。我们一直在为新的工作创建很多feature
和fix
分支,然后release
在它们完成时将它们合并到我们的分支中。在它们合并到正确的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. 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:
我注意到当这些分支被删除时,我将从我们的远程仓库中获取,但 EGit 不会从我的远程跟踪视图中删除它们。我的远程跟踪视图仍将显示不再位于远程仓库中的已删除分支(并且没有迹象表明它们已被删除)。(我发现)让我的远程跟踪视图反映实际存储库的唯一方法是手动删除我所有的远程跟踪分支(突出显示和删除),然后再次获取它们。这看起来很迂回,特别是因为您可以通过命令行修剪远程分支,如下所示:
git remote prune origin
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).Here is my current fetch configuration on my origin
remote:
基本上,我想知道的是,当远程跟踪分支更改时(在我获取之后),是否有一种方法可以配置/使 EGit 执行此修剪。这是我在origin
遥控器上的当前获取配置:
回答by VonC
Update March 2014: As mentioned by cheshire's answer, EGit 3.3added that prune feature.
2014 年 3 月更新:正如cheshire的回答所述,EGit 3.3添加了修剪功能。
You can see said feature introduced in this Gerrit code reviewin JGit(and tested here)
您可以在JGit 中的Gerrit 代码中看到所述功能(并在此处进行测试)
The entry fetch.prune
mentioned in git config
can be added to your Egit configuration:
中提到的条目fetch.prune
git config
可以添加到您的 Egit 配置中:
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
(在获取后运行),但出于安全原因在多用户环境中被删除。
回答by cheshire
The recent EGit 3.3 releaseintroduced 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
. When you fetch with EGit, this will automatically prune branches that are deleted on the central repository.
您可以在 gitconfig 中添加一个fetch.prune
或一个remote.<yourremotename>.prune
键并将其设置为true
. 当您使用 EGit 提取时,这将自动修剪在中央存储库中删除的分支。
回答by Joe.Hurke
Setting fetch.prune = true in the git-Settings solves the problem. 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. So you don't have to repeat it for each repository.
在 git-Settings 中设置 fetch.prune = true 可以解决问题。如果您在存储库设置中执行此操作,您可以为每个存储库设置不同的设置。如果您想对每个存储库使用此设置,您最好在用户设置中放置 fetch.prune = true。所以你不必为每个存储库重复它。