gh pr edit: Change PR Labels, Reviewers, Base
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
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.