跳转到内容
Try Gitea Cloud ☁️ for 30 days → Accelerate your Development & Deploys!
Support

Update a branch reference to a new commit

PUT
/repos/{owner}/{repo}/branches/{branch}
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" }'
owner
required
string

Owner of the repo

repo
required
string

Name of the repo

branch
required
string

Name of the branch

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"
}

APIEmpty is an empty response

Media typeapplication/json

APIForbiddenError is a forbidden error response

Media typeapplication/json
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
message
string
url
string