Compare reset --hard moving the branch pointer back (abandoning commits) with revert creating an undo commit — animated on the commit graph.
Scenario
Branch state
Current step 6/6
$ git reset --hard HEAD~3
reset --hard moves the branch pointer back. Commits no branch can reach are abandoned. Local-only — never reset commits others have pulled.
$ git log --oneline --all
c2 (HEAD -> main) wip 1
c1 init
File content (at HEAD) — app.js @ main
Circles are commits; dimmed circles were abandoned by rebase/reset. A prime (c3') means same content, rewritten hash. In sandbox mode, run commands yourself with the buttons.
reset and revert both undo work but in opposite ways. reset --hard moves the branch pointer back so later commits vanish from history, while revert adds a new commit that undoes the target — history is preserved.
Commits abandoned by reset become unreachable garbage: reflog can resurrect them for a while, but eventually they're collected. --hard also discards working-tree changes, so use it carefully.
For commits already pushed, revert is the only safe option. Resetting published commits forces a force-push that breaks your teammates' histories; revert just adds a commit, so it shares with a normal push. Git Branch Simulator