Skip to content

Instantly share code, notes, and snippets.

@rjchicago
Last active May 24, 2021 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjchicago/c33b74413703b071ebe5ae9e57275bf8 to your computer and use it in GitHub Desktop.
Save rjchicago/c33b74413703b071ebe5ae9e57275bf8 to your computer and use it in GitHub Desktop.
Sometimes you just want to reset everything and clean up with only the master branch again (locally). This script will reset hard, checkout master, and delete all local non-master branches.
git reset --hard && git checkout master && git branch | grep -v "^..master$" | xargs git branch -D && git pull
# add to ~/.bash_profile
# alias git-reset-master='git reset --hard && git checkout master && git branch | grep -v "^..master$" | xargs git branch -D && git pull'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment