Skip to content

GitHub Integration

LazyJJ integrates with GitHub CLI (gh) to create and manage stacked pull requests.

Prerequisites

Install GitHub CLI and authenticate:

Terminal window
# Install gh (see https://cli.github.com/)
brew install gh # macOS
# or your package manager
# Authenticate
gh auth login

PR Commands

CommandShortcutPurpose
pr-viewprvView current PR
pr-openproOpen current PR in browser
pr-stackprstackList bookmarks in stack
pr-stack-createsprsCreate/update stacked PRs
pr-stack-summaryprsGenerate PR stack summary
pr-stack-updateuprsUpdate PR comments with stack info
pr-stack-slackslackstackSlack-formatted PR stack

Basic Workflow

Terminal window
# View the PR for your current branch
jj pr-view
# Open it in the browser
jj pr-open

Stacked PRs

LazyJJ makes stacked PRs easy. First, create bookmarks for each commit:

Terminal window
# Create your stack
jj stack-start
jj describe -m "Add database schema"
jj bookmark-create db-schema
jj new
jj describe -m "Add user model"
jj bookmark-create user-model
jj new
jj describe -m "Add user API"
jj bookmark-create user-api

Then create/update all PRs at once:

Terminal window
# Create stacked PRs for all bookmarks
jj pr-stack-create

This will:

  1. Push each bookmark to the remote
  2. Create a PR for each bookmark
  3. Set the base branch correctly for stacking

PR Stack Summary

Generate a summary of your PR stack:

Terminal window
# Markdown format
jj pr-stack-summary
# Output:
# ## PR Stack
#
# - [user-api](https://github.com/...): Add user API
# - [user-model](https://github.com/...): Add user model
# - [db-schema](https://github.com/...): Add database schema

Update PR descriptions with the stack summary:

Terminal window
jj pr-stack-update

Slack Integration

Share your PR stack status in Slack:

Terminal window
jj pr-stack-slack
# Output:
# *PR Stack*
#
# :white_check_mark: <url|user-api>: Add user API
# :large_yellow_circle: <url|user-model>: Add user model
# :white_check_mark: <url|db-schema>: Add database schema

Understanding Bookmarks and Branches

One of the most common sources of confusion:

  • JJ calls them: Bookmarks
  • GitHub calls them: Branches
  • They’re the same thing

Why Bookmarks Don’t Auto-Follow

Unlike Git branches, JJ bookmarks stay where you set them:

Terminal window
jj bookmark-create my-feature # Bookmark at current commit
jj new -m "More work" # Create new commit
jj log
# my-feature is still at the old commit!
# Update manually:
jj bookmark set my-feature -r @

Research shows 11 out of 20 JJ resources mention this as a common confusion. See Common Mistakes for details.

The ghbranch Revset

LazyJJ provides a revset to find the current bookmark for GitHub:

Terminal window
# See which bookmark will be used
jj log -r ghbranch

Utility Commands

CommandShortcutPurpose
github-reporepoGet GitHub repo from origin
github-clighRun any gh command in repo context
Terminal window
# Get the repo name
jj github-repo # -> owner/repo
# Run any gh command
jj github-cli pr list
jj github-cli issue create

Tips

Finding the Right Bookmark

LazyJJ uses ghbranch to find the bookmark for the current position:

Terminal window
# See which bookmark will be used
jj log -r ghbranch

Rebasing After Merge

When a PR in your stack is merged:

Terminal window
# Sync with trunk (rebases your stack)
jj stack-sync
# Push updated stack
jj stack-submit

Manual PR Base

If you need to set a PR’s base manually:

Terminal window
gh pr edit my-branch --base other-branch

My Bookmark Didn’t Update

If you’re wondering why your bookmark didn’t move when you created a new commit, see Common Mistakes. This is THE most common confusion for Git users transitioning to JJ.

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