Skip to content

Instantly share code, notes, and snippets.

@bennycwong
Created August 17, 2016 01:05
Show Gist options
  • Select an option

  • Save bennycwong/5c9f6adfa9037f0940a0cc7c1a0359be to your computer and use it in GitHub Desktop.

Select an option

Save bennycwong/5c9f6adfa9037f0940a0cc7c1a0359be to your computer and use it in GitHub Desktop.
TIL: Clean up all branches except master (or another other rule you want)
git branch | grep -v master | xargs -n 1 git branch -D
git brach list branches
grep -v is a filter
xargs -n 1 pass in the arguments
git branch -D is the command.
This takes advantage of the pipe operator in *nix
Other versions
git branch --merged -> good for cleanup.
git branch --no-merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment