Diff and Checkout
Review pull request changes with local checkout and diff tooling.
Global options available on all PR commands: --json, --no-color, -w, --workspace, -r, --repo.
bb pr checkout
Section titled “bb pr checkout”Checkout a pull request locally. This command fetches the PR’s source branch and checks it out, creating a local tracking branch if needed.
bb pr checkout <id> [options]Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
id | Pull request ID |
Options
Section titled “Options”| Option | Description |
|---|---|
-w, --workspace <workspace> | Workspace |
-r, --repo <repo> | Repository |
--json | Output as JSON |
Examples
Section titled “Examples”# Checkout PR #42 to review locallybb pr checkout 42
# Checkout PR from specific repositorybb pr checkout 42 -w myworkspace -r myrepoThe command will:
- Fetch the latest changes from the remote
- Try to checkout the PR’s source branch
- If the branch doesn’t exist locally, create a new branch named
pr-<id>trackingorigin/<source-branch>
bb pr diff
Section titled “bb pr diff”View the diff of a pull request. Shows the changes introduced by the PR in unified diff format with syntax highlighting.
bb pr diff [id] [options]Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
id | Pull request ID (optional - auto-detects from current branch) |
Options
Section titled “Options”| Option | Description |
|---|---|
-w, --workspace <workspace> | Workspace |
-r, --repo <repo> | Repository |
--color <when> | Colorize output: auto, always, never (default: auto) |
--name-only | Show only names of changed files |
--stat | Show diffstat (files changed, insertions, deletions) |
--web | Open diff in web browser |
--json | Output as JSON |
Examples
Section titled “Examples”# View diff for PR #42bb pr diff 42
# Auto-detect PR from current branchbb pr diff
# Show only changed file namesbb pr diff 42 --name-only
# Show statistics (like git diff --stat)bb pr diff 42 --stat
# Open diff in browserbb pr diff 42 --web
# Return browser URL as JSONbb pr diff 42 --web --json
# Disable colors for piping to file or other commandsbb pr diff 42 --color never > pr-42.patch
# Get diffstat as JSON for scriptingbb pr diff 42 --stat --json- When no ID is provided, the command searches for an open PR where the source branch matches your current git branch
- The
--statoutput shows files changed with insertions (+) and deletions (-) -wremains the global short alias for--workspace; use--web(long form) to open the diff in a browser- Use
--color neverwhen piping output to files or other commands - Use the global
--no-colorflag to disable color output for all command formatting - The diff is colorized by default when output is a terminal (green for additions, red for deletions, cyan for hunk headers)