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.
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:
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:
git fetch --prune is the best utility for cleaning outdated branches. It will connect to a shared remote repository remote and fetch all remote branch refs. It will then delete remote refs that are no longer in use on the remote repository.
Steps to delete remote Git branchesIssue the git push origin –delete branch-name command, or use the vendor's online UI to perform a branch deletion. After the remote branch is deleted, then delete the remote tracking branch with the git fetch origin –prune command.
Pushing to delete remote branches also removes remote-tracking branches. Note that deleting the remote branch X from the command line using a git push will also remove the local remote-tracking branch origin/X , so it is not necessary to prune the obsolete remote-tracking branch with git fetch --prune or git fetch -p .
In order to clean up remote-tracking branches while fetching, use the “git fetch” command with the “–prune” option. Alternatively, you can simply use the “-p” shortcut instead of typing “prune” every time.
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).
Original answer (March 2013) EGit perform this pruning when remote tracking branches change (after I fetch). Not that I know of. More generally, perform any action after each fetch on the client side is not possible with hooks.
Right after they are merged into the correct releasebranch, these temporary branches are usually deleted to keep our remote repo clean. 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.
You can use the prune subcommand of git-remote for cleaning obsolete remote-tracking branches. Alternatively, you can use the get-fetch command with the --prune option to remove any remote-tracking references that no longer exist on the remote. That’s all about deleting remote-tracking branches in Git.
Update March 2014: As mentioned by cheshire's answer, EGit 3.3 added that prune feature.
You can see said feature introduced in this Gerrit code review in JGit (and tested here)
The entry fetch.prune
mentioned in git config
can be added to your Egit configuration:
Original answer (March 2013)
EGit perform this pruning when remote tracking branches change (after I fetch).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With