Skip to content

Instantly share code, notes, and snippets.

@mizanRahman
Last active July 11, 2016 18:08
Show Gist options
  • Select an option

  • Save mizanRahman/3a7887a2eaac789677579959b1dc9f5c to your computer and use it in GitHub Desktop.

Select an option

Save mizanRahman/3a7887a2eaac789677579959b1dc9f5c to your computer and use it in GitHub Desktop.
remove all branches that are merged into current branch

To delete all local branches that are already merged into the currently checked out branch:

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


To delete all branches on remote that are already merged:

git branch -r --merged | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin

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