Skip to content

Instantly share code, notes, and snippets.

@patmood
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmood/9557461 to your computer and use it in GitHub Desktop.
Save patmood/9557461 to your computer and use it in GitHub Desktop.
Delete all merged branches from a repo

Clean up old git branches

This will delete branches that have already been merged. Good for cleaning up local repos. Wont delete your current branch.

git branch --merged | grep -v "\*" | xargs -n 1 git branch -d

Saved here for my own reference but all credit to this guy: http://stevenharman.net/git-clean-delete-already-merged-branches

WARNING: This will only spare your current branch. Remember that you might lose master/staging/etc if you're not currently on that branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment