Update a reference
PATCH
/repos/{owner}/{repo}/git/refs/{ref}
Updates the provided reference to point to a new SHA. For more information, see “Git References” in the Git documentation.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ” owner
required
string
The account owner of the repository. The name is not case sensitive.
repo
required
string
The name of the repository without the .git extension. The name is not case sensitive.
ref
required
string
The Git reference. For more information, see “Git References” in the Git documentation.
Example
heads/feature-aRequest Body required
Section titled “ Request Body required ” Media type application/json
object
sha
required
The SHA1 value to set this reference to
string
force
Indicates whether to force the update or to make sure the update is a fast-forward update. Leaving this out or setting it to false will make sure you’re not overwriting work.
boolean
Examples
Example default
{ "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd", "force": true}Responses
Section titled “ Responses ”Response
Media type application/json
Git Reference
Git references within a repository
object
ref
required
string
node_id
required
string
url
required
string format: uri
object
required
object
type
required
string
sha
required
SHA for the reference
string
url
required
string format: uri
Examples
Example default
{ "ref": "refs/heads/featureA", "node_id": "MDM6UmVmcmVmcy9oZWFkcy9mZWF0dXJlQQ==", "url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/featureA", "object": { "type": "commit", "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd", "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd" }}Conflict
Media type application/json
Basic Error
Basic Error
object
message
string
documentation_url
string
url
string
status
string
Example generated
{ "message": "example", "documentation_url": "example", "url": "example", "status": "example"}Validation failed, or the endpoint has been spammed.
Media type application/json
Validation Error
Validation Error
object
message
required
string
documentation_url
required
string
errors
Array<object>
object
resource
string
field
string
message
string
code
required
string
index
integer
value
One of:
string
integer
Array<string>
Example generated
{ "message": "example", "documentation_url": "example", "errors": [ { "resource": "example", "field": "example", "message": "example", "code": "example", "index": 1, "value": [ "example" ] } ]}