Stack Workflow
LazyJJ provides a complete stack-based workflow for managing commits.
What is a Stack?
A “stack” is a series of commits from where you diverged from trunk to your current position. This model is perfect for:
- Feature development with multiple logical commits
- Stacked pull requests
- Code review workflows
Why Stacks Work Better in JJ
Unlike Git or Graphite, stacks are native to JJ’s model:
- Git: Branches fight the stacking workflow. Rebasing is manual and error-prone. You constantly juggle branch names and worry about detached HEAD states.
- Graphite: Stacks are metadata layered on top of Git. Break the discipline (one commit per branch), and the stack breaks. The “stack” is actually a queue fighting Git’s branch model.
- JJ: Stacks are the natural structure of the commit graph. Edit any commit, descendants automatically rebase. Change IDs provide stable handles. It’s how JJ works, not a layer on top.
Research insight: Graphite’s “stack” metaphor struggles because Git’s branch model wasn’t designed for it. JJ’s change-based model makes stacking natural.
For detailed understanding, see:
- Mental Model guide - Why JJ’s approach works
- Common Mistakes - Pitfalls to avoid
Viewing Stacks
| Command | Shortcut | Purpose |
|---|---|---|
stack-view | stack | View current stack with trunk context |
stack-files | stackls | Stack with file changes listed |
stacks-all | stacks | View all your stacks |
stacks-all-files | stacksls | All stacks with file changes |
# See your current stackjj stack-view
# See what files changed in each commitjj stack-files
# See all your work in progressjj stacks-allNavigation
| Command | Shortcut | Purpose |
|---|---|---|
stack-top | top | Jump to top of stack |
stack-bottom | bottom | Jump to bottom of stack |
# Go to the latest commit in your stackjj stack-top
# Go to the first commit in your stackjj stack-bottomSyncing with Trunk
| Command | Shortcut | Purpose |
|---|---|---|
stack-sync | sync | Fetch and rebase onto trunk |
stack-start | start | Fetch and start fresh from trunk |
stack-rebase | restack | Rebase stack onto trunk (no fetch) |
# Update your stack with latest trunkjj stack-sync
# Start a new stack from latest trunkjj stack-start
# Rebase without fetchingjj stack-rebasePushing and Bookmarks
| Command | Shortcut | Purpose |
|---|---|---|
stack-submit | ss | Smart push - push stack to remote |
bookmark-tug | tug | Move bookmark to parent commit |
bookmark-create | create | Create bookmark at parent commit |
# Push your stackjj stack-submit
# Move a bookmark to the previous commitjj bookmark-tug
# Create a new bookmark at the previous commitjj bookmark-create my-featureCleanup
| Command | Shortcut | Purpose |
|---|---|---|
stack-gc | gc | Abandon empty commits in stack |
# Clean up empty commitsjj stack-gcTypical Workflow
# Start fresh from trunkjj stack-start
# Make your changes, describe themjj describe -m "Add user authentication"
# Create next commitjj new
# Make more changesjj describe -m "Add login form"
# View your stackjj stack-view
# Sync with trunk if neededjj stack-sync
# Push for reviewjj stack-submitWorking with Multiple Stacks
# See all your stacksjj stacks-all
# Switch to a specific stackjj edit <commit-id>
# View that stackjj stack-view
Ernesto Jiménez