Skip to content
David Lanier edited this page Feb 12, 2015 · 3 revisions

How to clean up merged branches

Start in your main working copy.

Find merged branches

Have the branch checked out that you want to treat as canonical. The -a option lists all remote branches even if you haven't checked them out locally.

git checkout develop
git branch -a --merged

also, for reference: git branch -a --no-merged

Delete merged branches locally

git branch -d branch-name

Delete merged branches at remote

git push origin :branch-name

Now, in other checkouts of the same repo:

Remove local branches that no longer exist in remote.

git fetch origin
git remote prune origin --dry-run
git remote prune origin

Clone this wiki locally