# Choose Git revert, reset, or restore by what must change

Canonical: https://githtml.com/guides/git-revert-reset-restore-differences
Published: 2026-11-23
Publisher: WaveTech LLC / gitHtml

Use revert to create a new commit that reverses an earlier change, reset to change branch or index state according to its form, and restore to copy selected file content between states. These are not interchangeable undo buttons. First identify whether you need to change shared history, a local commit, staged content, or working files.

## Define the desired result before choosing a command

The request to undo a change is incomplete. You might want to remove a commit from an unpublished branch while keeping its edits, reverse a deployed fix through a new reviewable commit, unstage one file, or recover a deleted path. Each operation changes a different part of the repository and has different effects on collaborators.

Start by inspecting status, the recent log, and the remote relationship. Determine whether the relevant commit has been published and whether anyone else may depend on it. Preserve unrelated work before performing an operation that changes the index or working tree. A recovery plan should name the desired final state, not merely repeat the command that caused the problem.

## Match the operation to the state boundary

Revert usually suits shared history because it adds an explicit inverse commit rather than removing an existing one. Reset can move a local branch and optionally change the index or working files; its modes matter greatly. Restore is path-oriented and can discard working content if directed to replace it, so it also requires precise scope.

1. For an already shared commit, evaluate a revert and its behavioral consequences. Reverting a merge requires a deliberate mainline choice, not a generic recipe.
2. For an unpublished local commit, consider a soft or mixed reset only after verifying the target and preserving a recovery reference; avoid hard reset as routine cleanup.
3. For staging mistakes, restore --staged targets the index while retaining working edits. Restoring the working tree is a different, potentially destructive choice.

````shell
git status --short --branch
git log --oneline -5
git diff
git diff --staged
````

## Verify content and history separately

After the chosen operation, inspect both the files and the commit graph. A correct-looking file can coexist with an unintended branch rewrite, while the desired history shape can still leave stale or conflicted content. Run relevant tests when behavior changed and confirm that unrelated work remains present.

For example, reversing a released timeout change may need a new commit and a normal review, not removal of the original commit from the shared branch. Recovering one accidentally deleted configuration file may need only a path restore, not moving the entire branch backward. If the operation affects published history, coordinate before changing remote references. The safest undo workflow is specific about target, scope, preservation, and verification, and stops when any of those facts are unknown.

## Sources and further reading

- [Git reference: git-revert](https://git-scm.com/docs/git-revert)
- [Git reference: git-reset](https://git-scm.com/docs/git-reset)
- [Git reference: git-restore](https://git-scm.com/docs/git-restore)

## Related guides

- [Set a Git branch’s upstream deliberately](https://githtml.com/guides/git-set-upstream-tracking-branch)
- [Understand what a shallow Git clone leaves out](https://githtml.com/guides/git-shallow-clone-limitations)
- [Inspect one Git commit without checking it out](https://githtml.com/guides/git-show-inspect-one-commit)
- [Use sparse checkout for selected repository directories](https://githtml.com/guides/git-sparse-checkout-selected-directories)

Editorial approach: https://githtml.com/guides/about
