LinuxCommandLibrary

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.)

$ jj revert [[-r|--revisions]] [revsets]
copy

Apply the reverse on top of specified revisions
$ jj revert [[-r|--revisions]] [revsets] [[-d|--destination]] [revsets]
copy

Apply the reverse before and/or after specified revisions
$ jj revert [[-r|--revisions]] [revsets] [[-B|--insert-before]] [revsets] [[-A|--insert-after]] [revsets]
copy

SYNOPSIS

jj revert [OPTIONS] [REVSET...] [PATHS...]

PARAMETERS

-R, --reset <RESET>
    Reset mode: auto (default), working-copy, changes, tree

-r, --revision <REVSET>
    Revision(s) to revert from (default: @)

--to <REVSET>
    Revert toward these target revisions

--dry-run
    Preview changes without applying

--interactive
    Interactively edit diff before reverting

--tool <TOOL>
    Diff tool for interactive mode (default: auto)

-m, --message <TEXT>
    Commit message for new revert commit

--no-edit
    Skip editor for commit message

--git-backup
    Backup Git refs before operation

DESCRIPTION

Jujutsu (jj) is a Git-compatible distributed version control system (DVCS) focused on usability, performance, and working with large repositories. The jj revert command undoes changes introduced by specified revisions, creating an inverse commit or directly resetting the working copy.

By default, it reverts the working-copy commit (@) relative to its parents, effectively undoing recent modifications. Use --revision to target specific commits via revsets. The --to option reverts toward a target state instead of simple inversion.

Flexible reset modes via --reset allow affecting only the working copy, tracked changes, or the commit tree. Interactive mode enables diff editing before applying. Paths can be limited to specific files. Unlike git revert, which always merges a new commit, jj revert integrates with jj's operation log for cleaner history and supports Git interop.

Ideal for quick fixes, it preserves history while allowing precise control over what gets reverted.

CAVEATS

Requires jj installation; not a core Linux utility. Behavior may differ from Git in multi-parent repos. Use --dry-run first for safety.

EXAMPLES

jj revert
Revert working-copy changes.

jj revert @-1
Revert previous commit.

jj revert --revision main --interactive
Interactively revert from main.

REVSETS

Supports powerful revsets like @- (working copy parents), roots(), or branch(main) for precise targeting.

HISTORY

Jujutsu (jj) development began in 2022 by Martin von Zweigbergk (Google). First public release in 2023 (v0.1.0). jj revert introduced early for flexible undoing, evolving with revset support and Git compatibility by v0.18+.

SEE ALSO

jj(1), git-revert(1), jj-reset(1), jj-abort(1)

Copied to clipboard