Skip to content

Instantly share code, notes, and snippets.

@dennisroche
Last active March 16, 2016 06:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennisroche/9a53213c2bafe6a16dbc to your computer and use it in GitHub Desktop.
Save dennisroche/9a53213c2bafe6a16dbc to your computer and use it in GitHub Desktop.
Git, Prune Remote Branches that have been merged into origin/master
# Needs to executed in git bash, powershell with posh-git won't work.
# NB, change grep -v master to be the branch you want to check, e.g. grep -v development
# Preview
git fetch -p origin && git branch -r --merged | grep origin | grep -v '>' | grep -v master | xargs -L1 | cut -d"/" -f2- | xargs -d ' '
# Actual
git fetch -p origin && git branch -r --merged | grep origin | grep -v '>' | grep -v master | xargs -L1 | cut -d"/" -f2- | xargs git push origin --delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment