Skip to content

Instantly share code, notes, and snippets.

@jcf
Last active June 23, 2018 18:58
Show Gist options
  • Save jcf/f7014fe314e63c5552db to your computer and use it in GitHub Desktop.
Save jcf/f7014fe314e63c5552db to your computer and use it in GitHub Desktop.
Delete merged remote branches
# Assumes you want origin branches, ignoring `master`.
# Don't forget to to update your list of remote branches.
git remote prune origin
git branch -r --merged | \
awk '/origin/ && ! /HEAD/ && !/master/ { split($0, x, "/"); print x[2] }' | \
xargs -I x git push origin --delete x
@csi-lk
Copy link

csi-lk commented Jan 13, 2017

Worked like a charm thanks 👍

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