LinuxCommandLibrary

jj-restore

Restore files to a previous state

TLDR

Restore files from a revision into another revision

$ jj restore [[-f|--from]] [revset] [[-t|--into]] [revset] [filesets]
copy

Undo the changes in a revision as compared to the merge of its parents
$ jj restore [[-c|--changes-in]] [revset] [filesets]
copy

Interactively choose what parts to restore
$ jj restore [[-f|--from]] [revset] [[-t|--into]] [revset] [[-i|--interactive]]
copy

SYNOPSIS

jj restore [REVISION] [-r|--revision REVISION] [--from REVISION]

PARAMETERS


    Revision to restore from (default: @)

-r, --revision
    Explicit revision to fully restore working copy from (default: @)

--from
    Like --revision, but only restores differing changes from working copy

DESCRIPTION

jj restore is a Jujutsu (jj) command that resets the working copy tree to exactly match a specified revision, discarding all uncommitted changes including unstaged files and the working-copy commit itself. Jujutsu's working copy is always committed, so this operation effectively rebases or abandons changes to align with the target.

By default, it uses the @ (working-copy commit) as the source, which has minimal effect. Specify a REVISION (commit ID, branch, or ref) to restore from history. The --from option is more selective: it only updates parts of the working copy differing from the source revision, preserving matching files.

This is akin to git checkout -- . or git restore ., but leverages jj's immutable concurrent operations model for safer, faster restores. Ideal for cleaning up after experiments or syncing to a known state. Changes are lost unless committed or stashed first (use jj stash).

CAVEATS

Irreversibly discards uncommitted changes. No built-in confirmation; back up with jj stash or jj commit first. Ignores standard global options like --repository if unambiguous.

EXAMPLES

jj restore
Restore to current working-copy commit (no-op).

jj restore main
Discard changes and match main branch tree.

jj restore --from abc123
Apply only changes from commit abc123 to current WC.

HISTORY

Introduced in Jujutsu (jj) v0.1.0 (2022) by Martin von Zweigbergk at Google. Evolved to support --from in v0.5+ for finer control, aligning with jj's Git-compatible but operation-based design.

SEE ALSO

jj stash(1), jj new(1), git restore(1), git checkout(1)

Copied to clipboard