Skip to content

Instantly share code, notes, and snippets.

@palexs
Last active December 31, 2018 12:42
Show Gist options
  • Save palexs/3a0ba9b1553f0519c4de79b9c221411d to your computer and use it in GitHub Desktop.
Save palexs/3a0ba9b1553f0519c4de79b9c221411d to your computer and use it in GitHub Desktop.
Git useful commands
  • Remove all local branches except for master:

git branch | grep -v “master” | xargs git branch -D

  • Remove all remote (origin) branches except for master and HEAD:

git branch -r | grep origin/ | grep -v 'master$' | grep -v HEAD| cut -d/ -f2 | while read line; do git push origin :$line; done;

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