jj-revert
Revert a commit's changes
TLDR
Apply the reverse of the revisions specified by the given revsets (e.g. B::D, A..D, B|C|D, etc.)
Apply the reverse on top of specified revisions
Apply the reverse before and/or after specified revisions
SYNOPSIS
jj revert [OPTIONS] [REV]...
PARAMETERS
REV...
One or more revisions whose changes should be reverted. If omitted, the command defaults to reverting the changes introduced by the current working copy's parent commit.
-m, --message <MESSAGE>
Uses the provided string as the commit message for the new revert commit, bypassing the default editor.
-r, --revision <REVISION>
Specifies the revision to operate on. This can be used to select a single commit to revert or as context for other operations.
--tool <TOOL>
Determines the external tool to use for resolving conflicts that may arise during the revert operation.
--from <FROM_REV>
When reverting a range of commits, specifies the starting revision (inclusive) from which to revert changes.
--to <TO_REV>
When reverting a range of commits, specifies the ending revision (inclusive) up to which to revert changes.
--author <AUTHOR>
Sets the author for the new revert commit, overriding the default configured author.
--allow-backwards
Allows reverting a range of changes where the --from revision is a descendant of the --to revision. Normally, --from is expected to be an ancestor.
--edit
Opens an editor to allow modification of the commit message for the new revert commit.
--no-edit
Prevents an editor from opening for the commit message, using the default or a message provided via --message.
-v, --verbose
Increases the verbosity of the command's output, showing more details about the operation.
-q, --quiet
Suppresses most of the command's output, running silently.
DESCRIPTION
The jj revert command is used to undo changes introduced by one or more specific commits by creating a brand new commit. Unlike operations that rewrite history, jj revert applies the inverse of the original changes, effectively cancelling them out, and then records these inverse changes in a new commit. This approach preserves the original history, making it a safe and auditable method for undoing past modifications, especially in collaborative environments.
If the reversion process results in conflicts (e.g., if lines modified by the original commit were also changed by subsequent commits), jj revert will mark these conflicts in your working copy, requiring manual resolution before the new revert commit can be finalized. By default, if no specific revisions are provided, it reverts the changes introduced by the working copy's parent commit.
CAVEATS
The jj revert command creates a new commit; it does not alter or delete existing history. If conflicts occur during the revert process, they are marked in your working copy and require manual resolution before the new revert commit can be finalized. It's generally advisable to have a clean working copy before performing a revert to avoid unintended interactions with uncommitted changes.
CONFLICT RESOLUTION
Should jj revert encounter any merge conflicts while applying inverse changes, it will pause the operation, mark the conflicts in your working copy (e.g., using conflict markers), and prompt you to resolve them. You can use jj resolve or other merge tools to fix these conflicts before continuing and finalizing the revert commit.
REVERTING MULTIPLE COMMITS AND RANGES
jj revert is capable of reverting changes from multiple distinct commits by listing them as separate REV arguments. It can also revert a continuous range of commits by using the --from and --to options, which is useful for undoing a sequence of related changes efficiently.
HISTORY
Jujutsu (jj) is a relatively new, experimental distributed version control system, developed with the goal of providing a simpler and more powerful alternative to Git. Initiated around 2022, jj aims for a cleaner mental model and robust support for manipulating history. The revert command is a foundational feature, present from early development stages, embodying jj's commitment to providing safe and explicit ways to manage project history without destructive operations.