git revert --no-commit <commit>
This command lets you undo the changes introduced by a specific commit while pausing before actually committing, so you can review, adjust, or batch multiple reverts into a single commit.
It works by generating the inverse of the changes from <commit> and applying them to your working tree and index, but with --no-commit it stops short of creating the revert commit, leaving you to run git commit manually when you are ready. The revert subcommand tells Git to create a new commit that undoes changes from an earlier commit instead of rewriting history, and the --no-commit (same as -n) flag modifies this behavior so that the changes are only staged, not committed. The <commit> parameter is the commit you want to revert, which can be anything Git accepts as a commit-ish, such as a full SHA (for example a1b2c3d4), a branch name like main, or a relative reference like HEAD~2.
Because this command leaves the revert changes staged but uncommitted, you can tweak files before committing, combine reverts for several commits by running it multiple times, or even partially unstage some files with git reset before creating a final git commit with a custom message. This approach is especially useful when you want to preserve a clear, linear history (by avoiding git reset --hard) while still undoing mistakes or backing out features safely in shared branches.
Closely related variations include git revert <commit> (without --no-commit), which directly creates the revert commit; git revert -n <commit1> <commit2> ... to accumulate several reverts and then commit once; and git revert -m 1 <merge-commit> to revert a merge commit specifying the main parent. Other complementary commands are git show <commit> to inspect what you are about to revert, git log --oneline to find the commit hash, and git diff <commit>..HEAD to understand the impact before or after reverting.
Examples:
git revert --no-commit a1b2c3d4git revert --no-commit HEAD~1git revert --no-commit feature-branch~2