Skip to content

Instantly share code, notes, and snippets.

@mehmetsefabalik
Created January 24, 2021 12:14
Show Gist options
  • Save mehmetsefabalik/3795ca3cc2b6f0ab41a60382040a7ab3 to your computer and use it in GitHub Desktop.
Save mehmetsefabalik/3795ca3cc2b6f0ab41a60382040a7ab3 to your computer and use it in GitHub Desktop.

Remove local branches except master

git branch | grep -v '^*' | xargs git branch -D

Remove remote branches except master

REMOTE='origin' && MASTER='master' && git branch -r |  grep '^  ${REMOTE}/' | sed 's|^  ${REMOTE}/|:|' | grep -v '^:HEAD' | grep -v '^:${MASTER}$' | xargs git push ${REMOTE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment