Update a branch reference to a new commit
PUT
/repos/{owner}/{repo}/branches/{branch}
const url = 'https://gitea.example.com/api/v1/repos/example/example/branches/example';const options = { method: 'PUT', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"force":true,"new_commit_id":"example","old_commit_id":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://gitea.example.com/api/v1/repos/example/example/branches/example \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "force": true, "new_commit_id": "example", "old_commit_id": "example" }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”owner
required
string
Owner of the repo
repo
required
string
Name of the repo
branch
required
string
Name of the branch
Request Body
Section titled “Request Body”Media typeapplication/json
UpdateBranchRepoOption options when updating a branch reference in a repository
object
force
Force update even if the change is not a fast-forward
boolean
new_commit_id
required
New commit SHA (or any ref) the branch should point to
string
old_commit_id
Expected old commit SHA of the branch; if provided it must match the current tip
string
Examplegenerated
{ "force": true, "new_commit_id": "example", "old_commit_id": "example"}Responses
Section titled “Responses”APIEmpty is an empty response
Media typeapplication/json
APIForbiddenError is a forbidden error response
Media typeapplication/json
Headers
Section titled “Headers”message
string
url
string
APINotFound is a not found empty response
Media typeapplication/json
APIConflict is a conflict empty response
Media typeapplication/json
APIValidationError is error format response related to input validation
Media typeapplication/json
Headers
Section titled “Headers”message
string
url
string