gh pr checkout Switch to the branch of a pull request

Fetches the code from a pull request and checks it out as a local branch, so you can run or review it. It works for branches in forks as well.

Synopsis

gh pr checkout {NUMBER | URL | BRANCH} [FLAGS]

Common options

Option or formWhat it does
-b, --branch NAMELocal branch name to use
-f, --forceReset the local branch to match the pull request
--detachCheck out without creating a branch
--recurse-submodulesAlso update submodules

Examples

Check out pull request 42
gh pr checkout 42
Switched to branch 'feature/search'
Check out from a URL
gh pr checkout https://github.com/octocat/Hello-World/pull/42
Use your own branch name
gh pr checkout 42 --branch review-42
Look without making a branch
gh pr checkout 42 --detach

Notes

See also

Last reviewed 2026-10-09.