LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-revert

Create commits that undo previous changes

TLDR

Revert a commit
$ git revert [commit]
copy
Revert multiple commits
$ git revert [commit1] [commit2]
copy
Revert without committing
$ git revert -n [commit]
copy
Revert merge commit
$ git revert -m [1] [merge_commit]
copy
Continue after conflict
$ git revert --continue
copy
Abort revert
$ git revert --abort
copy

SYNOPSIS

git revert [options] commit...

DESCRIPTION

git revert creates new commits that undo the changes introduced by specified commits. Unlike `git reset`, it preserves history by adding inverse commits rather than removing existing ones.This makes it safe for shared branches where rewriting history would cause problems. Use `-m` to specify the mainline parent when reverting merge commits.

PARAMETERS

-n, --no-commit

Apply revert to working tree and index without creating a commit.
-e, --edit
Edit the commit message before committing (default when run interactively).
--no-edit
Use the default generated commit message.
-m parent-number, --mainline parent-number
Specify the mainline parent (1-based) when reverting a merge commit.
-s, --signoff
Add a `Signed-off-by` trailer to the commit message.
-S[keyid], --gpg-sign[=keyid]
GPG-sign the revert commit.
--cleanup=mode
Control how the commit message is cleaned up (see git-commit).
--strategy=strategy
Use the specified merge strategy.
-X option, --strategy-option=option
Pass an option through to the merge strategy.
--continue
Continue the revert operation after resolving conflicts.
--skip
Skip the current commit and continue with the remaining ones.
--abort
Cancel the in-progress revert and restore the pre-sequence state.
--quit
Forget about the current operation; leave index and working tree as-is.

SEE ALSO

Copied to clipboard
Kai