jj-restore
Restore files to a previous state
TLDR
Restore files from a revision into another revision
Undo the changes in a revision as compared to the merge of its parents
Interactively choose what parts to restore
SYNOPSIS
jj restore [OPTIONS] [PATHS...]
PARAMETERS
PATHS...
One or more paths to files or directories to restore. If no paths are specified, all files are considered for restoration.
--from REVISION
Specifies the source revision from which to copy the file content. Defaults to the working copy's parent commit if not specified.
--to REVISION
Specifies the target revision into which the files will be restored. Defaults to the working copy.
--allow-unmatched
Prevents the command from returning an error if some of the specified paths do not match any files in the source revision.
-n, --dry-run
Performs a dry run, showing which files would be affected without actually making any changes.
-h, --help
Displays a help message for the `jj restore` command.
DESCRIPTION
The `jj-restore` command in Jujutsu is used to copy specific files or directories from one revision's tree state to another, typically to the working copy. It is analogous to `git restore`, allowing users to undo local modifications, restore deleted files, or bring back files from a past version.
By default, `jj-restore` copies file content from the parent of the current working copy commit into the working copy itself. This effectively reverts any local changes made to those files since the last commit. Users can specify a different source revision using the `--from` option, enabling the restoration of files from any commit in the repository's history, or even from the working copy itself if desired (e.g., to restore a deleted file from the working copy back into the working copy from a source commit).
The `--to` option allows specifying the target revision where the files should be restored. By default, this is the working copy. When paths are provided, only those specific files or directories are affected. If no paths are given, the entire tree is restored from the specified source to the destination. `jj-restore` operates directly on the files and does not involve a separate staging area, aligning with Jujutsu's design philosophy of a mutable history.
CAVEATS
Using `jj-restore` can overwrite uncommitted local changes in your working copy if the target is the working copy. Always ensure you understand the source and target revisions to avoid unintended data loss. Jujutsu does not have a traditional staging area, so changes are applied directly.
HISTORY
Jujutsu (jj) is a relatively new and experimental version control system designed to offer a simpler and more intuitive interface than Git, focusing on a mutable history and rebase-first workflows. The `jj-restore` command is a fundamental part of its core functionality, providing a direct way to manage file states, mirroring essential capabilities found in more established VCS tools from its early development.
SEE ALSO
jj status(1), jj diff(1), jj checkout(1), git restore(1)