Skip to content

Instantly share code, notes, and snippets.

@JvanderHeide
Last active July 1, 2020 09:38
Show Gist options
  • Save JvanderHeide/40b804232b70f22b7561492ac345238e to your computer and use it in GitHub Desktop.
Save JvanderHeide/40b804232b70f22b7561492ac345238e to your computer and use it in GitHub Desktop.
Completely reset a git repository. I found this useful when testing external scripts etc. on a repo that modify and create files. Only use this if you're really sure you want to get rid of all your local changes.
# Added this prompt for safety's sake in case you wanted to add this to your profile
while true; do
read -p "Are your sure you want to completely reset your repository, including untracked files? (y/N) " yn
yn=${yn:-N}
case "$yn" in
[Yy]* ) break;;
[Nn]* ) exit;;
esac
done
# Or just copy this line but only use this if you're really sure you want to get rid of all your local changes.
git reset --hard && git clean -fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment