Navigate Your Stack
This tutorial covers navigating between commits in your stack.
Viewing Your Stack
First, understand where you are:
jj stack-viewOutput shows your position (@) and all commits:
@ xyz user-api "Add user API endpoints"○ abc user-model "Add user model"○ def db-schema "Add user database schema"○ trunkThe @ symbol shows your current position.
Jump to Top
Go to the newest commit in your stack:
jj stack-topUse this after editing a mid-stack commit to return to where you were.
Jump to Bottom
Go to the oldest commit in your stack (just above trunk):
jj stack-bottomUseful when you need to make foundational changes.
Edit Any Commit
Jump to a specific commit using its change ID:
# From jj stack-view, note the change ID (like "abc")jj edit abcNow your working copy is that commit. Any changes you make will modify it directly.
See All Your Stacks
If you have multiple features in progress:
jj stacks-allThis shows all your mutable commits across all stacks.
Checking Where You Are
Quick ways to see your current position:
# Full statusjj status
# Just the log showing current positionjj log-shortNavigation Example
Let’s say you need to fix something in the middle of your stack:
# View stack to find the commitjj stack-view
# Output:# @ xyz user-api "Add user API endpoints"# ○ abc user-model "Add user model"# ○ def db-schema "Add user database schema"# ○ trunk
# Edit the user-model commitjj edit abc
# Make your changesvim src/models/user.js
# Changes are automatically in that commit!# JJ rebases xyz (user-api) automatically
# Go back to topjj stack-topUnderstanding the Stack Model
In JJ, you’re always “inside” a commit. When you navigate:
jj edit xyz- You’re now editing commitxyz- Any file changes modify
xyzdirectly - Commits above
xyzare automatically rebased
What Navigation Means
- In Git: Checking out branches, switching between working trees
- In JJ: Entering a commit to edit it directly
This is different from Git where you’d need to:
- Checkout the branch
- Make changes
- Commit —amend
- Rebase dependent branches
JJ does all of this automatically. See the Mental Model guide for deeper explanation.
Working with Multiple Stacks
To switch between different feature stacks:
# See all your workjj stacks-all
# Edit a commit from a different stackjj edit <change-id-from-other-stack>
# View just that stackjj stack-viewTips
Use Tab Completion
JJ supports tab completion for change IDs. Type a few characters and press Tab.
Short Change IDs
Change IDs are unique, so you only need enough characters to identify them:
jj edit xy # Works if "xy" uniquely identifies a commitTip: Change IDs are visible in jj log output. The highlighted first few characters are usually enough to uniquely identify a commit.
Visual Stack View
For a detailed view with file changes:
jj stack-filesNext Steps
- Learn to Edit Mid-Stack Commits
- See how to Sync with Remote
- Check out Stack Workflow Reference
Ernesto Jiménez