Create a reference
POST
/repos/{owner}/{repo}/git/refs
Creates a reference for your repository. You are unable to create new references for empty repositories, even if the commit SHA-1 hash used exists. Empty repositories are repositories without branches.
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.
Request Body required
Section titled “ Request Body required ” Media type application/json
object
ref
required
The name of the fully qualified reference (ie: refs/heads/master). If it doesn’t start with ‘refs’ and have at least two slashes, it will be rejected.
string
sha
required
The SHA1 value for this reference.
string
Examples
Example default
{ "ref": "refs/heads/featureA", "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd"}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" }}Headers
Section titled “ Headers ” Location
string
Example
https://api.github.com/repos/octocat/Hello-World/git/refs/heads/featureAConflict
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" ] } ]}