Skip to content

Instantly share code, notes, and snippets.

@vaidehijoshi
Last active July 1, 2020 21:51
Show Gist options
  • Save vaidehijoshi/93db4adb0942f138df59c686cdaf04cb to your computer and use it in GitHub Desktop.
Save vaidehijoshi/93db4adb0942f138df59c686cdaf04cb to your computer and use it in GitHub Desktop.
clean up branches

To delete local branches which have alread been merged into master:

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

Omit the master branch argument to remove local branches which have already been merged into the current HEAD:

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

To delete all local branches except for master:

$ git branch | grep -v "master" | xargs git branch -D

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