git-reset-mechanics

Installation
SKILL.md

Git Reset Mechanics

Three trees: HEAD (last commit), Index (staged), Working (disk). reset walks them in order and stops by flag.

Flag HEAD ref Index Workdir WD-safe
--soft moves — — yes
--mixed (default) moves resets — yes
--hard moves resets resets NO

Reset vs Checkout (no path)

  • git reset --hard <ref> moves the branch HEAD points to; overwrites workdir without checking.
  • git checkout <ref> moves HEAD (detaches if a commit); refuses if unsaved changes conflict.

With a Path

git reset <commit> -- <path> copies commit→index, skips HEAD move (can't partially move a pointer). --hard with a path is rejected.

Installs
20
First Seen
Apr 18, 2026