| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Use the REST API to interact with references in your Git database on GitHub
A Git reference (git ref) is a file that contains a Git commit SHA-1 hash. When referring to a Git commit, you can use the Git reference, which is an easy-to-remember name, rather than the hash. The Git reference can be rewritten to point to a new commit. A branch is a Git reference that stores the new Git commit hash. These endpoints allow you to read and write references to your Git database on GitHub.
Returns an array of references from your Git database that match the supplied name. The :ref in the URL must be formatted as heads/<branch name> for branches and tags/<tag name> for tags. If the :ref doesn't exist in the repository, but existing refs start with :ref, they will be returned as an array.
When you use this endpoint without providing a :ref, it will return an array of all the references from your Git database, including notes and stashes if they exist on the server. Anything in the namespace is returned, not just heads and tags.
Note
You need to explicitly request a pull request to trigger a test merge commit, which checks the mergeability of pull requests. For more information, see "Checking mergeability of pull requests".
If you request matching references for a branch named feature but the branch feature doesn't exist, the response can still include other matching head refs that start with the word feature, such as featureA and featureB.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
ref string Required The Git reference. For more information, see "Git References" in the Git documentation. |
| Status code | Description |
|---|---|
| 200 | OK |
| 409 | Conflict |
Response
Returns a single reference from your Git database. The :ref in the URL must be formatted as heads/<branch name> for branches and tags/<tag name> for tags. If the :ref doesn't match an existing ref, a 404 is returned.
Note
You need to explicitly request a pull request to trigger a test merge commit, which checks the mergeability of pull requests. For more information, see "Checking mergeability of pull requests".
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
ref string Required The Git reference. For more information, see "Git References" in the Git documentation. |
| Status code | Description |
|---|---|
| 200 | OK |
| 404 | Resource not found |
| 409 | Conflict |
Response
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have at least one of the following permission sets:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
| Name, Type, Description |
|---|
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. |
| Status code | Description |
|---|---|
| 201 | Created |
| 409 | Conflict |
| 422 | Validation failed, or the endpoint has been spammed. |
Response
Updates the provided reference to point to a new SHA. For more information, see "Git References" in the Git documentation.
This endpoint works with the following fine-grained token types:
The fine-grained token must have at least one of the following permission sets:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
ref string Required The Git reference. For more information, see "Git References" in the Git documentation. |
| Name, Type, Description |
|---|
sha string Required The SHA1 value to set this reference to |
force boolean 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. Default: false |
| Status code | Description |
|---|---|
| 200 | OK |
| 409 | Conflict |
| 422 | Validation failed, or the endpoint has been spammed. |
Response
Deletes the provided reference.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
ref string Required The Git reference. For more information, see "Git References" in the Git documentation. |
| Status code | Description |
|---|---|
| 204 | No Content |
| 409 | Conflict |
| 422 | Validation failed, an attempt was made to delete the default branch, or the endpoint has been spammed. |
Response
| Back | FazBrowse Home | New Git URL |