# gh pr edit: Change PR Labels, Reviewers, Base

> gh pr edit updates a pull request title, body, labels, reviewers, milestone, or base branch. Reference for --add-label, --add-reviewer, and CI errors.

Source: https://latchkey.dev/learn/command-reference/gh-pr-edit  
Updated: 2026-06-30

gh pr edit modifies the metadata of an existing pull request without touching its commits.

Triage automation leans on gh pr edit to attach labels, assign reviewers, or retarget the base branch as a PR moves through its lifecycle.

## What it does

gh pr edit changes pull request fields: title, body, base branch, labels, assignees, reviewers, milestone, and projects. Add and remove flags let you adjust collections without replacing the whole set.

## Common usage

```Terminal
gh pr edit 123 --add-label "needs-review" --remove-label "wip"
gh pr edit 123 --add-reviewer octo-team
gh pr edit 123 --base main --title "Fix flaky test"
```

## Flags

| Flag | What it does |
| --- | --- |
| --add-label / --remove-label | Add or remove labels by name |
| --add-reviewer / --remove-reviewer | Request or drop reviewers |
| --add-assignee / --remove-assignee | Assign or unassign users (@me supported) |
| -B, --base <branch> | Change the target base branch |
| -t, --title / -b, --body | Update title or body |
| -F, --body-file <file> | Read the new body from a file |

## In CI

Set GH_TOKEN and permissions: { pull-requests: write }. Adding a label that does not exist fails, so create labels first with gh label create. Requesting a reviewer requires that the user or team has access to the repository.

## Common errors in CI

"GraphQL: Resource not accessible by integration" means the token lacks pull-requests: write. "could not add label: 'X' not found" means the label is missing; create it first. "GraphQL: Review cannot be requested from pull request author" occurs when you try to add the author as a reviewer.

## Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

```.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### gh pr edit: Change PR Labels, Reviewers, Base?

Triage automation leans on gh pr edit to attach labels, assign reviewers, or retarget the base branch as a PR moves through its lifecycle.

### What it does?

gh pr edit changes pull request fields: title, body, base branch, labels, assignees, reviewers, milestone, and projects. Add and remove flags let you adjust collections without replacing the whole set.

### In CI?

Set GH_TOKEN and permissions: { pull-requests: write }. Adding a label that does not exist fails, so create labels first with gh label create. Requesting a reviewer requires that the user or team has access to the repository.

### Common errors in CI?

"GraphQL: Resource not accessible by integration" means the token lacks pull-requests: write. "could not add label: 'X' not found" means the label is missing; create it first. "GraphQL: Review cannot be requested from pull request author" occurs when you try to add the author as a reviewer.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
