---
title: "Update a pull request branch"
method: PUT
path: "/repos/{owner}/{repo}/pulls/{pull_number}/update-branch"
tags: ["pulls"]
---

# Update a pull request branch

`PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch`

Updates the pull request branch with the latest upstream changes by merging HEAD from the base branch into the pull request branch.
Note: If making a request on behalf of a GitHub App you must also have permissions to write the contents of the head repository.

## Path parameters

- `owner` string, required
- `repo` string, required
- `pull_number` integer, required

## Request body

- object, nullable
  - `expected_head_sha` string — The expected SHA of the pull request's HEAD ref. This is the most recent commit on the pull request's branch. If the expected SHA does not match the pull request's HEAD, you will receive a `422 Unprocessable Entity` status. You can use the "[List commits](https://docs.github.com/enterprise-cloud@latest/rest/commits/commits#list-commits)" endpoint to find the most recent commit SHA. Default: SHA of the pull request's current HEAD ref.

## Response `202`

Response

- object
  - `message` string
  - `url` string

## Other responses

- `403` — Forbidden
- `422` — Validation failed, or the endpoint has been spammed.

---

[API](https://skmtc.net/github/apis/github-v3-rest-api-2.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-2/versions/8ae6d0c8716e/schema)
