git reset --soft HEAD~1 undoes the last commit and keeps the changes staged, ready to commit again. Reset moves the branch pointer back one commit. Your files on disk never change.
git reset --soft HEAD~1 # commit undone, changes stay staged
git reset HEAD~1 # same, but changes end up unstaged
The default mode, --mixed, keeps the work unstaged instead. The --hard mode throws away your edits, so avoid it here.
Reset only moves your local branch, so use git revert HEAD for a commit you already pushed. Revert adds a new commit that undoes the old one, and nobody's history is rewritten.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓