Skip to content

Instantly share code, notes, and snippets.

@garrow
Last active November 22, 2016 23:24
Show Gist options
  • Save garrow/3fa40758be3f85e924d87a1702cb9b24 to your computer and use it in GitHub Desktop.
Save garrow/3fa40758be3f85e924d87a1702cb9b24 to your computer and use it in GitHub Desktop.
Delete all remote merged branches

Delete all remote merged branches

This will;

  • Lists all remote merged branches
  • Exclude master branch
  • Exclude stable branch
  • Remove the origin/ prefix
  • Push the deletion (one by one)
git branch --list --color=never --remotes --merged origin/master | \
  grep -v master | \
  grep -v stable  | \
  cut -d/ -f2- | \
  xargs -n1  git push origin --delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment