Reset & Revert
A shared commit added a debug entry. How can I undo that and keep later work?
You can say this to an AI Agent
Commit C accidentally added a debug entry, and a teammate later made D. Review the diffs for C and D, then use git revert C to append an offsetting commit. Explain possible conflicts and only resolve the parts related to C. Confirm B’s navigation and D’s content remain, the debug entry is gone, rerun the page, and tell me the new commit hash.
When to use it
- For an unshared commit, consider reset only after checking staged and working-tree changes$ git reset --hard HEAD~1HEAD is now at 3f9c2ab Adjust navigation spacing
- Keep changes but redo the commit with --soft$ git reset --soft HEAD~1Changes stay staged; restage and commit after tidying up
- For a shared commit, consider revert and check for conflicts$ git revert a1b2c3d[main 9e8f7a6] Revert "Add debug code by mistake"
- Before --hard, inspect tracked-file changes it will replace in the index and working treegit status shows uncommitted changesreset --hard discards these changes too
When NOT to use it
- Reset a shared branch and force push without coordinating with teammatesForce pushing after resetting a pushed commit splits teammates' copiesDo not rewrite shared history; use revert
- Run reset --hard without checking which tracked-file changes it will replaceTwo hours of uncommitted work disappear with reset --hardRun git status first to confirm
- Revert without reviewing later edits that may overlap and need conflict resolutionReverted a teammate's commit without telling themThey keep building on reverted work, creating needless conflicts
- Skip verification after undoingreset ✓→The page errors
Use git log / git show to confirm the target commit and its changes first.
Reset updates the branch, index, and working tree according to its mode. --hard replaces tracked working-tree changes, so check status first.
This does not move shared C or the teammate's D. If later edits overlap with C, revert may also require manual conflict resolution.
| B | Navigation update remains |
| C | Original commit stays in history |
| D | Teammate's help copy remains |
| E | Offsets C's debug entry |
Run the page and inspect affected paths. If revert overlaps later work, resolve the conflict too.
Select page elements for precise AI edits
Click a button, text, or card, note the change, then copy its exact location to AI.
Open Selector Pro website↗