Skip to main content

Create a reference

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.

POST/repos/{owner}/{repo}/git/refs
Source
github-v3-rest.json
Revision
f5f067c1e6f6
Active snapshot
85e53e3d0d65

Request

Path Parameters
owner string
required
repo string
required
Body Params
required
application/jsonobject
key string
optional

Example: "refs/heads/newbranch"

ref string
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.

sha string
required

The SHA1 value for this reference.

Responses

application/json Git Reference object

Response

Headers
Location string

Example: https://api.github.com/repos/octocat/Hello-World/git/refs/heads/featureA

node_id string
required
object object
required
sha string
required

SHA for the reference

Example: 7638417db6d59f3c431d3e1f261cc637155684cd

type string
required
url string<uri>
required
ref string
required
url string<uri>
required
application/json Validation Error object

Validation failed

documentation_url string
required
errors array[object]
optional
items object
code string
required
field string
optional
index integer
optional
message string
optional
resource string
optional
value
optional
message string
required