It would be nice if you could right-click on the origin after creating/removing branches and do a git remote prune origin, to remove from the local cache all the remote branches that no longer exist.
Our workflow is:
This means that we tend to have lots of task-related branches that can build up very quickly. At present, there's no way to remove these easily - we don't want to run the risk of deleting any branches that should be there, so a cleanup of local tends to wait a while as these build up. Finding the git remote origin prune command helped out quite a bit, but it's still a command-prompt step. Integrating this into GitLens would go a long way to not having to recall arcane command-line commands!
It would be nice if there was also a way to remove the local tracking branches as well; that's a much more manual process, but would be a feel-good improvement,
Hell yeah - only thing missing as far as I can see
Right now, you have an option to right-click on a branch and delete local via the ternminal.
which does something like:
git branch -d Sprint-1.4
Could this not also be simple done, but instead do a pull and prune?
git pull --prune
?
馃憤 I'd like such a feature. It can be done as suggested here by using this command line :
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -D
A integrated Delete local branches not on master feature would be great though.
@zaboyle If you are looking for another command to add -- this one is quite similar to the one you just added 馃槈
@eamodio For sure, I'll give it a shot!
@zaboyle Thanks for looking into this. @LazerFX I was wondering, does your feature request includes pruning local tracking branches that do not exist on remote anymore ? That was what I was interested about. Thanks.
That's what the command does, yes... It's really useful if (like me) you end up making lots of small branches for small features, and then roll them up at the end of a week or two...
I agree, that is a useful tool. That just brings up the question of whether or not it should be separate from just a 'prune', or if the 'prune' should also remove these local branches. @eamodio what's your take?
well my take is I want to be able to prune the local dead branches, and ideally be able to do that remotely. In the best case I would have a list of each and be able to interactively choose the ones I want to keep.
@zaboyle I definitely don't want to mix pruning with deleting local branches -- prune is a known git option and I wouldn't want to confuse that with unexpected behaviors, especially a destructive one.
I would suggest keeping prune as-is and then opening a new issue for deleting (in bulk) branches. IMO, the best place for something like that is via the new _Git Commands_ command by adding a new _branch_ and then _remove_ option.
It could also eventually be added to the tree views once multi-select support that is coming soon in vscode ships.
@eamodio Sounds good! When I get the chance, I'll mark the PR for the prune feature as ready for review, and open a new issue for removing the "dead" local branches.
Just made an issue for this over at #817 馃憤
Most helpful comment
It would be nice if there was also a way to remove the local tracking branches as well; that's a much more manual process, but would be a feel-good improvement,