Viewing History and Diffs
jj provides powerful tools for exploring history and comparing changes.
Viewing History
git
git logjj
jj log| git | jj |
|---|---|
| git log | jj log |
Log Options
git
git log --onelinegit log -n 10git log --graph --onelinejj
jj log -l 10jj log --graphjj log --all| git | jj |
|---|---|
| git log --oneline | jj log -l 10 |
| git log -n 10 | jj log --graph |
| git log --graph --oneline | jj log --all |
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
git
git show HEADjj
jj show @| git | jj |
|---|---|
| git show HEAD | jj show @ |
Viewing Diffs
git
git diffgit diff app.jsgit diff HEAD~1 HEADjj
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
git
git statusjj
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
git
git diff HEAD app.jsgit diff branch1 branch2 app.jsjj
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
# Make some changes
echo "test" > test.txt
echo "demo" > demo.txt
# See what changed
jj diff
# Commit them
jj describe -m "Add files"
jj new
# View the commit
jj show @-
# See history
jj log
# Compare with parent
jj diff --from @- --to @
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.