Skip to content

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:

Viewing Stacks

CommandShortcutPurpose
stack-viewstackView current stack with trunk context
stack-filesstacklsStack with file changes listed
stacks-allstacksView all your stacks
stacks-all-filesstackslsAll stacks with file changes
Terminal window
# See your current stack
jj stack-view
# See what files changed in each commit
jj stack-files
# See all your work in progress
jj stacks-all
CommandShortcutPurpose
stack-toptopJump to top of stack
stack-bottombottomJump to bottom of stack
Terminal window
# Go to the latest commit in your stack
jj stack-top
# Go to the first commit in your stack
jj stack-bottom

Syncing with Trunk

CommandShortcutPurpose
stack-syncsyncFetch and rebase onto trunk
stack-startstartFetch and start fresh from trunk
stack-rebaserestackRebase stack onto trunk (no fetch)
Terminal window
# Update your stack with latest trunk
jj stack-sync
# Start a new stack from latest trunk
jj stack-start
# Rebase without fetching
jj stack-rebase

Pushing and Bookmarks

CommandShortcutPurpose
stack-submitssSmart push - push stack to remote
bookmark-tugtugMove bookmark to parent commit
bookmark-createcreateCreate bookmark at parent commit
Terminal window
# Push your stack
jj stack-submit
# Move a bookmark to the previous commit
jj bookmark-tug
# Create a new bookmark at the previous commit
jj bookmark-create my-feature

Cleanup

CommandShortcutPurpose
stack-gcgcAbandon empty commits in stack
Terminal window
# Clean up empty commits
jj stack-gc

Typical Workflow

Terminal window
# Start fresh from trunk
jj stack-start
# Make your changes, describe them
jj describe -m "Add user authentication"
# Create next commit
jj new
# Make more changes
jj describe -m "Add login form"
# View your stack
jj stack-view
# Sync with trunk if needed
jj stack-sync
# Push for review
jj stack-submit

Working with Multiple Stacks

Terminal window
# See all your stacks
jj stacks-all
# Switch to a specific stack
jj edit <commit-id>
# View that stack
jj stack-view

Project by Ernesto Jiménez Ernesto Jiménez Bluesky GitHub