---
title: "Update a branch reference to a new commit"
method: PUT
path: "/repos/{owner}/{repo}/branches/{branch}"
tags: ["repository"]
---

# Update a branch reference to a new commit

`PUT /repos/{owner}/{repo}/branches/{branch}`

## Path parameters

- `owner` string, required
- `repo` string, required
- `branch` string, required

## Request body

- UpdateBranchRepoOption — UpdateBranchRepoOption options when updating a branch reference in a repository
  - `force` boolean — Force update even if the change is not a fast-forward
  - `new_commit_id` string, required — New commit SHA (or any ref) the branch should point to
  - `old_commit_id` string — Expected old commit SHA of the branch; if provided it must match the current tip

## Response `204`

APIEmpty is an empty response

## Other responses

- `403` — APIForbiddenError is a forbidden error response
- `404` — APINotFound is a not found empty response
- `409` — APIConflict is a conflict empty response
- `422` — APIValidationError is error format response related to input validation

---

[API](https://skmtc.net/gitea/apis/gitea-api.md) · [All operations](https://skmtc.net/gitea/apis/gitea-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/gitea/gitea-api/revisions/350de506cefa/schema)
