Skip to content

Instantly share code, notes, and snippets.

@chenrui333
Created August 27, 2019 22:44
Show Gist options
  • Save chenrui333/fd2a67dccbb28c62ca3b2c0400d0a75d to your computer and use it in GitHub Desktop.
Save chenrui333/fd2a67dccbb28c62ca3b2c0400d0a75d to your computer and use it in GitHub Desktop.
cleanup merged branches

cleanup the merged branches

git branch -r --merged | 
grep origin | 
grep -v '>' | 
grep -v master | 
xargs -L1 | 
cut -d"/" -f2- | 
xargs git push origin --delete

prune the branches which have been removed in origin: git fetch --prune origin

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