Skip to content

Instantly share code, notes, and snippets.

@icanhazstring
Last active March 19, 2019 16:21
Show Gist options
  • Save icanhazstring/d7f2d82403841c148f47858f8cb763c8 to your computer and use it in GitHub Desktop.
Save icanhazstring/d7f2d82403841c148f47858f8cb763c8 to your computer and use it in GitHub Desktop.
Git delete multiple remote merged branches
# git branch -r --merged master
## List all remote merged branches (master)
# awk -Forigin/ '/\/PVKZU-/ {print $2}'
## remove origin/ prefix
# tr '\n' ' '
## Replace new line with space (to get one single argument)
# xargs -rt git push origin --delete
## remove all list branches in one single execution
git branch -r --merged master | awk -Forigin/ '/\/PVKZU-/ {print $2}' | tr '\n' ' ' | xargs -rt git push origin --delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment