Restarting
Important
Yoou learn to clean up your working area completely and start over.
The jj restore --help page states:
When neither
--fromnor--intois 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 restoreAdded 1 files, modified 2 files, removed 1 filesjj stThe 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:
| Goal | Git |
|---|---|
| Discard unstaged changes | git restore . |
| Discard both staged and unstaged changes | git 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