Automatically Delete Merged Local Branches in Towergit
Keep your local branch list tidy by letting Towergit delete branches after they are merged—learn the local-only limits before enabling it.
24 Apr 2026, 17:33 UTC

Merged branches that stick around
After a feature branch is merged into the main line, it often remains in the local branch list. Over time, the list grows stale, and it becomes harder to tell which branches are active and which are already part of history. Towergit includes a setting that attempts to solve this by removing local branches automatically after a successful merge.
The useful takeaway: enable this setting only after you confirm it covers your workflow, because it deletes local branches only and leaves remote-tracking references untouched.
How the cleanup setting works
When the option is enabled, Towergit watches for a merge commit that incorporates a feature branch. Once the merge succeeds, it issues git branch -d for that branch. Git’s built-in safety check means the command refuses to delete a branch that has not been fully merged, so unmerged work is not removed by this feature alone.
Open Towergit, go to Preferences → Git, and look for “Delete merged branches automatically.” The setting is disabled by default in some older Towergit releases. Check your installed version against the current release notes before assuming the default behavior.
Worked example: clean up a feature branch
- Create a short-lived branch in your repository:
git checkout -b feature/login-form
- Make a commit, push if needed, and open a pull request or merge request as usual.
- Merge the branch through Towergit’s UI.
- If the setting is enabled, the branch should disappear from the local branch list immediately after the merge.
- Confirm from the command line:
git branch --merged
The merged branch should no longer appear in that list. Note that remote-tracking branches such as origin/feature/login-form are not removed by this Towergit setting. To clean those, run:
git remote prune origin
Run commands in a terminal inside the repository with normal user permissions. git branch -d fails safely if the branch is not fully merged; using git branch -D instead forces deletion and can discard unmerged work, so avoid it unless you intend to discard changes.
Limitations and risks
- Local branches only. Remote-tracking refs remain until you prune them separately.
- Hot-fix branches can disappear. If a merged branch is still needed for an urgent follow-up, automatic deletion removes it before you have a chance to recreate the context.
- Version-dependent defaults. Some older Towergit versions ship this setting disabled; verify your version rather than assuming it is on or off.
- Merge detection depends on the UI flow. Branches merged outside Towergit may not trigger the automatic cleanup.
Check before you enable it
- Run
towergit --versionin your terminal and compare the result with Towergit’s release notes to confirm which version you have. - Open Towergit → Preferences → Git and toggle “Delete merged branches automatically.”
- Test with a scratch branch you do not need: merge it, then confirm it is gone from the local branch list and from
git branch --merged. - If remote-tracking branches clutter your list, add
git remote prune originto your cleanup routine or configure fetch pruning in your Git client.
Automatic branch cleanup reduces noise, but it is not a substitute for reviewing what you delete. Enable it, test it with a disposable branch, and keep a manual prune step for remote-tracking refs.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.