Skip to content

Instantly share code, notes, and snippets.

@l15n
Forked from schacon/gist:942899
Last active September 17, 2021 16:17
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save l15n/7112231 to your computer and use it in GitHub Desktop.
Save l15n/7112231 to your computer and use it in GitHub Desktop.
Delete all remote branches on your fork `mine` which have already been merged into upstream `origin/master`
$ git branch --merged master |
grep -v '*' |
grep -v master |
xargs -L1 |
xargs git branch -d
$ git branch -r --merged origin/master |
grep mine |
grep -v '>' |
grep -v master |
xargs -L1 |
xargs git branch -r -d
$ git branch -r --merged origin/master |
grep mine |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push mine --delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment