Git by Situation

Not an alphabetical list of commands. Structured around what you're actually trying to do — or fix.

18 situations

18 situations

Commands
git reset HEAD~1

Undo commit, keep changes unstaged

git reset --soft HEAD~1

Undo commit, keep changes staged

git reset --hard HEAD~1

Undo commit AND delete all changes (destructive)

If you already pushed to remote, you'll need git push --force (warn teammates first)

undoresetcommitmistake