gh pr checkout
Fetch a pull request's branch and switch to it
What it does
gh pr checkout 42 fetches the branch of pull request 42, creates a matching local branch and switches to it. You do not need to find out what the branch is called or where it lives: it works for PRs from other people's forks too.
This is how you check a PR before reviewing it: run the tests, try the app. Getting back to your own work is a plain git switch <branch>.
Syntax
gh pr checkout <number>Examples
Switch to the branch of pull request 42 to run it locally
gh pr checkout 42pr checkout— fetch the PR's branch and switch to it42— the pull request number
Related commands
- gh pr diff — See the changes of a pull request
- gh pr review — Approve a pull request or ask for changes
- git switch — Switch to another branch, or create a new one and switch to it