Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Restarting

Important

Yoou learn to clean up your working area completely and start over.

The jj restore --help page states:

When neither --from nor --into is specified, the command restores into the working copy from its parent(s).

This means:

jj restore

is equivalent to:

jj restore -f @- -t @ .

It makes your Current Change identical to its parent, providing a convenient way to wipe your slate clean and start over.

Give it a try. Select any Change and create a new Change on top:

jj new ru

Make random modifications:

touch unnecessary.txt
echo "a bug" >> src/App.js
rm src/index.js
jj status
Working copy changes:
M public/index.html
M src/App.js
D src/index.js
A unnecessary.txt

You have 2 modified, 1 deleted, and 1 added file.

Warning

How do you start over and return to an empty Change?

Tip

Trivial!

jj restore
Added 1 files, modified 2 files, removed 1 files
jj st
The working copy has no changes.

Back to the start.

Isn’t This equivalent to git restore?

Not really. Git spreads state across HEAD, the Index, the working tree, and untracked files. You need different commands based on the layer you target:

GoalGit
Discard unstaged changesgit restore .
Discard both staged and unstaged changesgit restore --staged --worktree . or git reset --hard HEAD
Clean restart (equivalent to jj restore)git reset --hard HEAD && git clean -fd
Nuclear cleanup (includes .gitignore files)git reset --hard HEAD && git clean -fdx

followed by:

git clean -fd