Viewing History and Diffs
jj provides powerful tools for exploring history and comparing changes.
Viewing History
jj
jj log| git | jj |
|---|---|
| git log | jj log |
Log Options
jj
jj log -l 10| git | jj |
|---|---|
| git log --oneline | jj log -l 10 |
| git log -n 10 | |
| git log --graph --oneline |
Understanding the Log Output
In jj's log:
@= Your working copy commit◉= Regular commits◌= Abandoned commits@appears in the log as the latest commit
$ jj log
@ xyzkpznx test 123
◉ prklqyso test foo
◉ roqmyuqs test bar
◉ yostqsxx qux
Viewing Commit Details
jj
jj show @| git | jj |
|---|---|
| git show HEAD | jj show @ |
Viewing Diffs
jj
jj diffjj diff app.jsjj diff --from @- --to @| git | jj |
|---|---|
| git diff | jj diff |
| git diff app.js | jj diff app.js |
| git diff HEAD~1 HEAD | jj diff --from @- --to @ |
Diff Syntax
jj uses --from and --to for precise diff control:
# Compare @ with parent
jj diff --from @- --to @
# Compare two commits
jj diff --from abc --to def
# Compare with main
jj diff --from main --to @
# See what changed since main
jj diff --from main
Common Diff Patterns
What changed in my working copy?
jj diff
What's different between two branches?
jj diff --from main --to feature
Show me the changes in this commit:
jj show abc
# or
jj diff --from abc^- --to abc
What files are modified?
jj status
The Status Command
jj
jj status| git | jj |
|---|---|
| git status | jj status |
Interactive History
jj's log is more than just text—it's an interactive history:
# View log with more details
jj log -v
# Show change IDs
jj log --change-id
# Show commit timestamps
jj log --timestamps
Comparing Files
jj
jj diff app.jsjj diff --from branch1 --to branch2 app.js| git | jj |
|---|---|
| git diff HEAD app.js | jj diff app.js |
| git diff branch1 branch2 app.js | jj diff --from branch1 --to branch2 app.js |
Operations Log
jj maintains an operation log—useful for undoing:
# Show operation history
jj op log
# Output:
# 0123 minutes ago: checkout
# 0456 minutes ago: new
# 0789 minutes ago: describe
Try It Yourself
$
$
$
$
$
$
Key Takeaways
jj logshows commit history with@marking working copyjj diffshows @ vs parent (use--from/--tofor more)jj showdisplays full commit detailsjj statusshows pending changesjj op logshows operation history for undo
Next Steps
Now let's explore how jj handles remote operations differently from git.