Prune merged local branches (e.g when fetching)

Theodoros Antoniou 3 years ago updated by Thomas Singer 7 months ago 14

When fetching from a remote, allow the choice to prune (delete) any local branches, which are tracking a remote branch that has been merged.

This is quite a common task, especially if you work in a team that uses a lot of feature branches and Pull Requests. Stackoverflow related question

P.s: This is a feature available in SourceTree.

I don't understand the argument "especially if you work in a team that uses a lot of feature branches and Pull Requests". Could you please describe your work-flow?


Sure, it's a pretty standard PR workflow. We are using an Atlassian stack, so Jira for tickets and Bitbucket for git repo.

  1. Dev creates a local work branch, such as feature-JIRA123 or bugfix-JIRA456
  2. Dev pushes to origin and creates a PR in Bitbucket.
  3. Another Dev reviews the PR, approves and merges into master using the Bitbucket UI
    • the reviewer can choose to delete the merged branch from the remote via the Bitbucket UI
  4. The devs can now fetch the new changes from remote master

At this point the local work branch (e.g feature-JIRA123) can be safely deleted from the dev's local repo, as it's tracking branch has already been merged and deleted from origin. This is what I believe SmartGit can automate by giving an option during fetch.

The stackoverflow question I linked provides various command line solutions for this and I am currently using one of them, but it would be nice if this was part of SmartGit.


I've been wishing for this feature for a long time. The "features" tree gets cluttered really fast even on small projects.


I also support that request! We're using the BitBucket as well and have the very same workflow as described.

I would also like to be able to prune merged branches from my commit graph.

A common use-case for me is that I want to see a graph with ONLY a feature branch and the shared branch the feature branch was cut from.    But not only do I see those two branches, but I see every branch that got merged into the shared branch.

I was using Tower (which has this feature) before migrating to SmartGit (a lot more stable) but I really miss "Prune Obsolete Remote Branches" option in SmartGit.

I frequently get a warning saying "There are too many unreachable loose objects; run 'git prune' to remove them." Maybe this reflects an issue with my git server, I haven't looked into it. But it's kind of stupid that SmartGit doesn't have any way to run prune, despite the fact that it recommends doing so. So I have to open up a terminal window like an animal, manually cd to my repo, and type the command out. Like an animal! Avoiding this kind of thing is precisely why I paid $100 for this dang software.

Of course, SmartGit has this feature: Local | Run Garbage Collector - but it is completely unrelated to this request.

SmartGit has an option "Pull: prune obsolete remote tracked branches" in the repository settings since a long time. What further option do you need?

It's not working. I expect that fetch only deletes them, but it doesn't.

Maybe we're misunderstanding the feature, but from I've been using SmartGit for 4 years now and I have never seen it delete a merged local branch after a fetch. It will mark with a red ?missing (or something similar), which is still useful and I have gotten used to that for now.

Is the feature deleting the tracking branch, but not the local branch?


I want local branch deleted. Did I understand this feature correctly? Tower has this and it is awesome. We have GitLab behind and when merge request is merged, remote branch is deleted on server, and local branch should be deleted also (if there are no commits that were not pushed).

All red missing branches should be automatically deleted.

What exact Git commands Tower is using?