Pull requests
Update a pull request's branch
Bring a pull request's branch up to date with its base: update_method merge (the default) makes a merge commit on its branch that takes in the base's new commits; rebase makes each of its commits again on top of the base's head and moves its branch there, rewriting its history.
/repos/{owner}/{name}/pulls/{number}/update-branchPushed as you, so you must be able to push to its branch: the Write role for a branch of the repository, its owner for a working copy, and push access to the fork for a branch of a fork. With expected_head_sha, refused (409) if its head is no longer that commit. Edits to the same file merge line by line; a rebase drops merge commits and commits the base already has, keeps authors, dates and messages, and moves its branch only if its head is still where it was. Returns outcome: updated (with commit, its head now, and previous), up_to_date, or needs_agent when both sides changed the same lines (with reason, detail and the paths): nothing was pushed, so merge or rebase in a clone and push.
outcome is updated (its branch moved from previous to commit), up_to_date (it already holds its base’s head; commit only) or needs_agent (nothing was pushed: reason is overlap, conflicting or unsupported, with detail and the paths concerned). update_method rebase rewrites its branch, so pull it again before pushing more. A head that moved since expected_head_sha answers 409. See Keeping a pull request up to date.
- Authentication: Required. Send an access token as
Authorization: Bearer. - MCP tool:
pull_requestwithactionupdate_branch, and the same inputs - Scope: An access token needs
pull_requests:write.
Path parameters
Section titled “Path parameters”| Name | Type | Required | Description |
|---|---|---|---|
owner |
string | Yes | The workspace that owns the repository. |
name |
string | Yes | The repository’s name. |
number |
integer | Yes | The number shown after the #. Issues and pull requests share one sequence. |
Body parameters
Section titled “Body parameters”Send a JSON object. Names are snake_case, as in responses; the camelCase spelling is accepted too.
| Name | Type | Required | Description |
|---|---|---|---|
expected_head_sha |
string | No | The head commit you saw: refused (409) if the pull request’s head has moved since. |
update_method |
string | No | merge (the default): a merge commit on its branch takes in the base’s new commits. rebase: its commits are made again on the base’s head, rewriting its branch. One of merge, rebase. |
Example request
Section titled “Example request”curl -X PUT https://api.g1t.sh/repos/flagon-io/hello/pulls/14/update-branch \ -H "Authorization: Bearer $G1T_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "expected_head_sha": "9f2c4e1a7b3d5f60812a4c6e8b0d2f4a6c8e0b13", "update_method": "merge" }'Example response
Section titled “Example response”A successful request answers 200 with:
{ "outcome": "updated", "commit": "5b8d0f2a4c6e8a0c2e4a6c8e0a2c4e6a8c0e2a4c", "previous": "9f2c4e1a7b3d5f60812a4c6e8b0d2f4a6c8e0b13"}Errors
Section titled “Errors”A failed request answers with one of these statuses and a body like {"error": {"code": "not_found", "message": "Repository not found."}}. See errors.
| Status | Code | When |
|---|---|---|
| 401 | unauthenticated |
A token is required, or the one sent is not valid. |
| 403 | forbidden |
The token is valid but not allowed to do this, such as a member-only change, or a token without the scope it needs. |
| 404 | not_found |
It does not exist, or you cannot see it. |
| 409 | conflict |
The request conflicts with the current state. |
| 422 | invalid |
The input is not valid. message says which field and why. |