Diff and Checkout
Review pull request changes with local checkout and diff tooling.
Global options available on all PR commands: --json [fields], --jq <expression>, --no-color, -w, --workspace, -r, --repo.
bb pr checkout
Section titled “bb pr checkout”Check out a pull request’s source branch locally.
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, in order:
- Fetches the latest changes from the remote
- Checks out the pull request’s source branch
- If that checkout fails, creates a local branch
pr-<id>trackingorigin/<source-branch>
--json returns { success, pullRequestId, branch, pullRequest }, where branch is whichever of the two names was checked out.
bb pr diff
Section titled “bb pr diff”View the diff of a pull request in unified diff format.
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--stat output:
src/index.ts | +12 -3src/utils.ts | +4docs/README.md | -8
3 files changed, 16 insertions(+), 11 deletions(-)- When no ID is provided, the command searches for an open pull request whose source branch matches your current git branch
--color autocolors the diff only when stdout is a terminal: green for additions, red for deletions, cyan for hunk headers. Whole lines are colored by their leading marker — there is no language-aware highlighting--color neverforces plain text, which is what you want when redirecting to a file or piping into another command. The global--no-colorflag does the same for every command- The value is validated before the request. A typo fails with
--color must be one of: auto, always, neverplus a(Did you mean never?)suggestion, rather than silently falling back - Passing
--color <when>at all turns the global color setting on, because the CLI resolves color by scanning raw argv for a--colortoken.bb pr diff 42 --color neverstill leaves the diff body uncolored, but it overrides--no-colorandNO_COLORfor everything else that invocation prints. See Global Flags → Precedence summary -wis the global short alias for--workspace. To open the diff in a browser you must spell out--web- For opening other Bitbucket pages (PR detail, files, commits, pipelines, settings) in the browser, see
bb browse