Undo a local Jujutsu operation
Use a disposable jj repository to inspect the operation log and undo an accidental change description.
how-to4 steps
Updated
in short
Jujutsu records repository operations. Inspect that history with jj op log and use jj undo to back out the last operation.
Use the small fixture below to check the workflow before applying it to your own project.
Tools used
Before you start
- A Bash or Zsh terminal on Linux or macOS
- The listed tools installed and available on PATH
Steps
Step 1: Create a disposable repository
This example has no remote. Configure an example identity for this repository only.
shtrmn_guide_dir="$(mktemp -d)" cd "$trmn_guide_dir" jj git init . jj config set --repo user.name 'Guide Example' jj config set --repo user.email 'guide@example.invalid' printf 'first draft\n' > note.txt jj describe -m 'first draft'Step 2: Change the description by mistake
The file content stays the same; only the change description is replaced.
shjj describe -m 'wrong description' jj log -r @ --no-graph -T 'description'outputwrong description
Step 3: Inspect the operation log
Look for the describe operation. Operation IDs and timestamps vary by run.
shjj op log --limit 4Step 4: Undo and verify
Run this immediately after inspecting the log, before making another repository change.
shjj undo jj log -r @ --no-graph -T 'description' cat note.txt
Further reading
[Jujutsu operation log](https://docs.jj-vcs.dev/latest/operation-log/)
FAQ
- Does undo mean delete the latest file edit?
- It undoes a repository operation. Here it restores a description. Inspect the operation log before using it on real work.
- Can this undo something on a remote server?
- This exercise is entirely local. Do not assume a local undo reverses an already-pushed remote change.