Skip to content

Instantly share code, notes, and snippets.

@revgum
Forked from aarti/git_prune_branches
Created April 22, 2017 14:51
Show Gist options
  • Save revgum/68b51ebdf36749911254135b79b1562a to your computer and use it in GitHub Desktop.
Save revgum/68b51ebdf36749911254135b79b1562a to your computer and use it in GitHub Desktop.
Delete unused git branches
→ git remote prune origin
→ git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
# Remember to do this from the master branch
# If you run it from a feature branch the master branch gets deleted.
→ git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
Deleted branch master (was 644eb76).
You can recheckout master branch
→ git checkout -b master origin/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment