Choose How to Undo With git reset Modes

Use --soft, --mixed or --hard to control what survives a reset.

macOSdiffgitcliLow risk
Run git reset --soft HEAD~1 to move HEAD back while keeping changes staged.

01Command

Command
$ git reset --soft HEAD~1

02What it does

reset moves the current branch and optionally updates the index and working tree: soft keeps everything staged, mixed (default) unstages, hard discards. Knowing the modes is what lets you reshape local history precisely from the shell.

03Risk

RiskLow risk
RequirementsGit 2.20+ (install with Homebrew or Xcode Command Line Tools)
CompatibilitymacOS with Git installed (Homebrew or Xcode Command Line Tools)
!Warning: --hard permanently discards uncommitted changes; commit or stash first if the work matters.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • git-reset documentation
    Git · vendor-doc · 2026-09-20
    Evidence: Documents soft, mixed and hard reset and their effect on index and working tree.

Last verified: 2026-10-13 · Category: Developer