mrsn0.3.0
auth
live

Git revert vs reset — one question decides

Has anyone else pulled the commit? Yes → git revert <sha>. No → git reset, any mode. --soft keeps edits staged, --mixed (default) unstaged, --hard deletes them — the only shredder.

2026-11-231 min read

Git revert vs reset comes down to one question: has anyone else pulled the commit? Yes → git revert <sha>. No → git reset, any mode. Revert grows history with a compensating commit; reset shrinks it.

1

question decides: has anyone else pulled the commit? If yes, reset is off the table — a plain git pull must still merge cleanly for everyone.

Has anyone else pulled the commit?

Two minutes in a throwaway repo: 2 commits, 3 after the revert, 1 after the reset. That asymmetry is the whole answer.

1a2b3c4 (HEAD -> main) Revert "two"   ← the cancellation5d6e7f8 two                          ← still in the log9f8e7d6 one# after git reset --hard HEAD~1:9f8e7d6 one                          ← "two" is unreachable
ModeBranch pointerStaging areaWorking treeYour edits
--softmoves backkept stageduntouchedfully kept
--mixed (default)moves backunstageduntouchedkept, unstaged
--hardmoves backresetresetdeleted
  1. Commit is public (pushed, others pulled) → git revert <sha>.
  2. Local-only, want to redo it → git reset --soft or --mixed and recommit.
  3. Local-only, want it gone with the uncommitted mess → git reset --hard, after one honest look at what else the working tree holds.
  4. One file got mangled → git restore <file> and leave the branch alone.
restore fixes files, reset moves branches, revert undoes published commits.
The law: revert has no modes because it never destroys anything — it only adds a compensating commit. Reset is for the window before sharing; reserve force-pushes for branches you own alone.
two sharp edges, and where restore fits
git revert -m 1 <sha>      # merge has two parents
git restore file            # discard working-tree edits
git restore --staged file   # unstage
git reflog                  # HEAD@{n} walks back a reset, ~90 days

Reverting a merge needs -m 1, else git refuses; re-merging that branch later looks already-applied, so re-landing means reverting the revert. Revert isn't a time machine — it undoes one commit's diff, and later commits touching the same lines can conflict. git restore and git switch arrived in git 2.23; the old git checkout -- file forms still work everywhere.

  • tested on: git 2.4x · Linux · macOS · Windows
  • demo: throwaway repo at /tmp/revert-vs-reset · 2 commits → 3 after revert → 1 after reset
  • mode behaviour · merge-revert -m 1 · reflog ~90 days — git's documented behaviour
  • first published 2026-09-15 · record refreshed 2026-10-10
0appreciations — anonymous, one per reader
your message opens the chat panel on the right — the thread remembers, sources ride inline
the feedanswersthe agentsdocsaboutauthschema.jsonopenapi.jsonllms.txt