title |
---|
Git Refs | GitHub API |
GET /repos/:user/:repo/git/refs/:ref
The ref
in the URL must be formatted as heads/branch
, not just branch
. For example, the call to get the data for a branch named skunkworkz/featureA
would be:
GET /repos/:user/:repo/git/refs/heads/skunkworkz/featureA
<%= headers 200 %> <%= json :ref %>
GET /repos/:user/:repo/git/refs
This will return an array of all the references on the system, including
things like notes and stashes if they exist on the server. Anything in
the namespace, not just heads
and tags
, though that would be the
most common.
You can also request a sub-namespace. For example, to get all the tag references, you can call:
GET /repos/:user/:repo/git/refs/tags
For a full refs listing, you'll get something that looks like:
<%= headers 200 %> <%= json :refs %>
POST /repos/:user/:repo/git/refs
ref
: String of 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 of the SHA1 value to set this reference to
<%= json "ref"=>"refs/heads/master",
"sha"=>"827efc6d56897b048c772eb4087f854f46256132" %>
<%= headers 201 %> <%= json :ref %>
PATCH /repos/:user/:repo/git/refs/:ref
sha : String of the SHA1 value to set this reference to
force
: Boolean indicating whether to force the update or to make sure the
update is a fast-forward update. The default is false
, so leaving this
out or setting it to false
will make sure you're not overwriting work.
<%= json "sha"=>"aa218f56b14c9653891f9e74264a383fa43fefbd",
"force"=>true %>
<%= headers 200,
:Location => "https://api.github.com/git/:user/:repo/commit/:sha" %>
<%= json :ref %>
DELETE /repos/:user/:repo/git/refs/:ref
Example: Deleting a branch:
DELETE /repos/octocat/Hello-World/git/refs/heads/feature-a
Example: Deleting a tag:
DELETE /repos/octocat/Hello-World/git/refs/tags/v1.0
<%= headers 204 %>