Skip to content
LatchkeyLatchkey home

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

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

FlagWhat it does
--add-label / --remove-labelAdd or remove labels by name
--add-reviewer / --remove-reviewerRequest or drop reviewers
--add-assignee / --remove-assigneeAssign or unassign users (@me supported)
-B, --base <branch>Change the target base branch
-t, --title / -b, --bodyUpdate 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

Frequently asked questions

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.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card