git-reset-mechanics
Skill0 starsChanged 39 days agoMITView on GitHub
Use when undoing commits, unstaging files, or choosing between reset/checkout/restore — clarifies which tree each variant touches and when --hard is unsafe
- Deletes or force-pushes
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- postgres-locking-joinsSkill
- ai-bug-patternsSkill
- compressed-ndjson-boundariesSkill
- http-resume-integritySkill
- linux-io-latency-triageSkill
- macos-disk-space-recoverySkill
- minimal-sufficient-evidenceSkill
- modularize-large-filesSkill
- patch-reproducer-validitySkill
- prompt-cache-boundariesSkill
- proton-drive-selective-backupSkill
- transactional-outbox-deliverySkill
- conventional-commitsSkill
- git-advanced-mergingSkill
- git-bisect-forensicsSkill
- git-data-recoverySkill
- git-hooksSkill
- git-rerereSkill
- git-revisions-syntaxSkill
- git-rewriting-historySkill
- git-submodulesSkill
- git-worktreesSkill
- github-ssh-keysSkill
- npm-publish-ci-pitfallsSkill
- sapling-stacked-pr-workflowSkill
- go-concurrency-patternsSkill
- go-data-idiomsSkill
- go-error-handlingSkill
- go-interfaces-embeddingSkill
- go-pprof-profilingSkill
- marketing-funnel-diagnosisSkill
- marketing-geo-experimentsSkill
- marketing-incrementalitySkill
- marketing-positioning-testsSkill
- python-descriptors-mroSkill
- python-logging-cookbookSkill
- python-scaling-regression-testsSkill
- python-unicode-gotchasSkill
- rust-compile-time-invariantsSkill
- rust-deterministic-concurrency-testsSkill
- rust-error-identity-boundariesSkill
- rust-regex-search-contractsSkill
- rust-runtime-bug-classesSkill
- rust-tokio-actor-deliverySkill
- rust-tokio-cancellation-safetySkill
- sales-discovery-qualificationSkill
- sales-mutual-action-plansSkill
- sales-pipeline-forecast-calibrationSkill
- sales-value-negotiationSkill
- ai-triage-evaluationSkill
- container-image-patchingSkill
- dependency-artifact-integritySkill
- dnssec-sentinel-diagnosticsSkill
- iam-policy-change-replaySkill
- rbvm-applicabilitySkill
- rbvm-asset-evidenceSkill
- rbvm-guarded-remediationSkill
- rbvm-priority-decisionsSkill
- rbvm-risk-exceptionsSkill
- The first 60 shown.
The file
Files
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.
git checkout <commit> -- <path> copies commit→index and workdir — destructive. Prefer modern restore:
git restore --staged <path>— unstagegit restore <path>— discard workdir changegit restore --source=<ref> -SW <path>— both
Patterns
git reset --soft HEAD~ # undo commit, keep staging
git reset HEAD~ # undo commit + unstage
git reset --hard HEAD~ # undo + discard (destructive)
git reset --soft HEAD~3 && git commit # squash last 3
git reset --patch # unstage hunksPitfalls
--hardis the only destructive common flag — no prompt. Recovery:git reflog→git reset --hard HEAD@{1}.- Reset on a pushed branch rewrites history others have. Use
revertinstead.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

