git reset moves the branch pointer backward, optionally changing the staging area and working directory:
# --soft: move HEAD only — changes stay staged
git reset --soft HEAD~1
# --mixed (default): move HEAD + unstage — changes in working dir
git reset HEAD~1
git reset --mixed HEAD~1 # same thing
# --hard: move HEAD + discard ALL changes (dangerous!)
git reset --hard HEAD~1
--soft — "I want to re-commit these changes differently"--mixed — "I want to keep my changes but un-commit them"--hard — "Throw everything away and go back" (cannot be undone easily!)# Undo last commit, keep files unchanged
git reset HEAD~1
# Undo last 3 commits, keep all changes staged
git reset --soft HEAD~3
You made two bad commits. Use git reset --soft HEAD~2 to undo both commits while keeping the file changes staged, then re-commit everything as one commit with message "Single clean commit".
Click "Run" to execute your code.