jj-undo
Undo previous Jujutsu command
TLDR
Undo the last operation
SYNOPSIS
jj undo [OPTIONS]
PARAMETERS
-r, --revision <REVISION>
Undo specific operation revision instead of the last one [default: last_operation()]
--dry-run
Preview changes without applying them
-v, --verbose
Increase output verbosity for details
-q, --quiet
Reduce output verbosity
DESCRIPTION
The jj undo command is a key feature of Jujutsu (jj), a Git-compatible version control system designed for efficiency with large repositories. It reverts the effects of the most recent jj operation, restoring both the repository state and working copy to their prior condition. Jujutsu maintains an operation log, a record of all changes made by jj commands, enabling precise undo without data loss.
By default, it undoes the last operation (identified as last_operation()). This is safer than traditional reset commands because it targets operations explicitly, avoiding accidental loss of uncommitted work. Use cases include correcting mistaken commits, reverts, or abandons. The command updates the working copy, staging area, and commit graph accordingly.
For targeted undos, specify a revision with --revision. The --dry-run option previews changes without applying them. Verbose output helps diagnose complex scenarios. Importantly, jj undo only affects jj operations; manual file changes or external tools require separate handling.
This operation-based model sets Jujutsu apart, supporting non-linear workflows and automatic conflict resolution.
CAVEATS
Only undoes jj operations, not external changes. Multiple undos may require chaining. Use --dry-run first in complex repos.
EXAMPLES
jj undo
Undo last operation.
jj undo --revision abc123
Undo specific operation.
jj undo --dry-run -v
Preview verbose dry-run.
OPERATION LOG
View with jj op log to identify revisions for targeted undo.
HISTORY
Introduced in Jujutsu v0.1.0 (April 2022) by Martin von Zweigbergk. Evolved with operation log in v0.5+ for reliable undo across Git-compatible workflows.


