# gh pr checkout

Switch to any PR branch, including forks.

## Quick answer
```
gh pr checkout 123
```

## Syntax
```
gh pr checkout {<number> | <url> | <branch>} [flags]
```

## Examples

# Check out PR #123 by number
gh pr checkout 123

# Check out by full URL
gh pr checkout https://github.com/cli/cli/pull/123

# Check out into a differently named local branch
gh pr checkout 123 --branch review-123

# Update submodules while checking out
gh pr checkout 123 --recurse-submodules

# Detach HEAD instead of creating a branch
gh pr checkout 123 --detach

## Key flags

  -b, --branch	Local branch name to use instead of the PR's head branch name.
  --detach	Check out the PR in detached HEAD state.
  -f, --force	Reset the existing local branch to the latest state of the PR.
  --recurse-submodules	Update all submodules after checkout.

Full guide: https://ghcli.com/gh-pr-checkout.php
