GitHub Integration
LazyJJ integrates with GitHub CLI (gh) to create and manage stacked pull requests.
Prerequisites
Install GitHub CLI and authenticate:
# Install gh (see https://cli.github.com/)brew install gh # macOS# or your package manager
# Authenticategh auth loginPR Commands
| Command | Shortcut | Purpose |
|---|---|---|
pr-view | prv | View current PR |
pr-open | pro | Open current PR in browser |
pr-stack | prstack | List bookmarks in stack |
pr-stack-create | sprs | Create/update stacked PRs |
pr-stack-summary | prs | Generate PR stack summary |
pr-stack-update | uprs | Update PR comments with stack info |
pr-stack-slack | slackstack | Slack-formatted PR stack |
Basic Workflow
# View the PR for your current branchjj pr-view
# Open it in the browserjj pr-openStacked PRs
LazyJJ makes stacked PRs easy. First, create bookmarks for each commit:
# Create your stackjj stack-startjj describe -m "Add database schema"jj bookmark-create db-schemajj new
jj describe -m "Add user model"jj bookmark-create user-modeljj new
jj describe -m "Add user API"jj bookmark-create user-apiThen create/update all PRs at once:
# Create stacked PRs for all bookmarksjj pr-stack-createThis will:
- Push each bookmark to the remote
- Create a PR for each bookmark
- Set the base branch correctly for stacking
PR Stack Summary
Generate a summary of your PR stack:
# Markdown formatjj 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 schemaUpdate PR descriptions with the stack summary:
jj pr-stack-updateSlack Integration
Share your PR stack status in Slack:
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 schemaUnderstanding 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:
jj bookmark-create my-feature # Bookmark at current commitjj new -m "More work" # Create new commitjj 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:
# See which bookmark will be usedjj log -r ghbranchUtility Commands
| Command | Shortcut | Purpose |
|---|---|---|
github-repo | repo | Get GitHub repo from origin |
github-cli | gh | Run any gh command in repo context |
# Get the repo namejj github-repo # -> owner/repo
# Run any gh commandjj github-cli pr listjj github-cli issue createTips
Finding the Right Bookmark
LazyJJ uses ghbranch to find the bookmark for the current position:
# See which bookmark will be usedjj log -r ghbranchRebasing After Merge
When a PR in your stack is merged:
# Sync with trunk (rebases your stack)jj stack-sync
# Push updated stackjj stack-submitManual PR Base
If you need to set a PR’s base manually:
gh pr edit my-branch --base other-branchMy 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.
Ernesto Jiménez