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 | - | 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-md | prmd | Formatted PR stack with CI/review status |
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 create db-schemajj new
jj describe -m "Add user model"jj create user-modeljj new
jj describe -m "Add user API"jj 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-updateUnderstanding 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. Update manually with jj bookmark set my-feature -r @. 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 |
gh | - | Run any gh command in repo context |
# Get the repo namejj github-repo # -> owner/repo
# Run any gh commandjj gh pr listjj gh 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
See Common Mistakes.
Ernesto Jiménez