Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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