Skip to content

Instantly share code, notes, and snippets.

@cmpute
Created April 27, 2020 15:27
Show Gist options
  • Save cmpute/a0615b8d4c2f0459c8aa6c655c48f005 to your computer and use it in GitHub Desktop.
Save cmpute/a0615b8d4c2f0459c8aa6c655c48f005 to your computer and use it in GitHub Desktop.
My cheatsheet of Git

Delete all remote branches

git branch -r | grep <remote> | cut -c 10- | xargs -n 10 git push <remote> --delete

Useful for clean forked repository. 10 in cut -c 10- here represents the length of string <remote>\ 10 in xargs -n 10 represents how many branch to delete at a time, sometimes detele will report error, so less branches a time can reduces number of branched to be deleted manually

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