Références Git
Utilisez l’API REST pour interagir avec les références de votre base de données Git sur GitHub AE.
À propos des références Git
Une référence Git (git ref) est un fichier qui contient un hachage SHA-1 de validation Git. Lorsque vous faites référence à une validation Git, vous pouvez utiliser la référence Git, qui est un nom facile à mémoriser, plutôt que le hachage. La référence Git peut être réécrite pour pointer vers une nouvelle validation. Une branche est une référence Git qui stocke le nouveau hachage de validation Git. Ces points de terminaison vous permettent de lire et d’écrire des références à votre base de données Git sur GitHub AE.
List matching references
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.
Parameters
| Headers |
|---|
| Nom, Type, Description |
acceptstringSetting to |
| Path parameters |
| Nom, Type, Description |
ownerstringRequiredThe account owner of the repository. The name is not case sensitive. |
repostringRequiredThe name of the repository. The name is not case sensitive. |
refstringRequiredref parameter |
HTTP response status codes
| Status code | Description |
|---|---|
200 | OK |
Code samples
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/git/matching-refs/REFResponse
Status: 200[
{
"ref": "refs/heads/feature-a",
"node_id": "MDM6UmVmcmVmcy9oZWFkcy9mZWF0dXJlLWE=",
"url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/feature-a",
"object": {
"type": "commit",
"sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
}
},
{
"ref": "refs/heads/feature-b",
"node_id": "MDM6UmVmcmVmcy9oZWFkcy9mZWF0dXJlLWI=",
"url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/feature-b",
"object": {
"type": "commit",
"sha": "612077ae6dffb4d2fbd8ce0cccaa58893b07b5ac",
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/612077ae6dffb4d2fbd8ce0cccaa58893b07b5ac"
}
}
]Get a reference
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".
Parameters
| Headers |
|---|
| Nom, Type, Description |
acceptstringSetting to |
| Path parameters |
| Nom, Type, Description |
ownerstringRequiredThe account owner of the repository. The name is not case sensitive. |
repostringRequiredThe name of the repository. The name is not case sensitive. |
refstringRequiredref parameter |
HTTP response status codes
| Status code | Description |
|---|---|
200 | OK |
404 | Resource not found |
Code samples
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/git/ref/REFResponse
Status: 200{
"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"
}
}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.
Parameters
| Headers |
|---|
| Nom, Type, Description |
acceptstringSetting to |
| Path parameters |
| Nom, Type, Description |
ownerstringRequiredThe account owner of the repository. The name is not case sensitive. |
repostringRequiredThe name of the repository. The name is not case sensitive. |
| Body parameters |
| Nom, Type, Description |
refstringRequiredThe name of the fully qualified reference (ie: |
shastringRequiredThe SHA1 value for this reference. |
keystring |
HTTP response status codes
| Status code | Description |
|---|---|
201 | Created |
422 | Validation failed, or the endpoint has been spammed. |
Code samples
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/git/refs \
-d '{"ref":"refs/heads/featureA","sha":"aa218f56b14c9653891f9e74264a383fa43fefbd"}'Response
Status: 201{
"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"
}
}Update a reference
Parameters
| Headers |
|---|
| Nom, Type, Description |
acceptstringSetting to |
| Path parameters |
| Nom, Type, Description |
ownerstringRequiredThe account owner of the repository. The name is not case sensitive. |
repostringRequiredThe name of the repository. The name is not case sensitive. |
refstringRequiredThe name of the fully qualified reference to update. For example, |
| Body parameters |
| Nom, Type, Description |
shastringRequiredThe SHA1 value to set this reference to |
forcebooleanIndicates whether to force the update or to make sure the update is a fast-forward update. Leaving this out or setting it to Default: |
HTTP response status codes
| Status code | Description |
|---|---|
200 | OK |
422 | Validation failed, or the endpoint has been spammed. |
Code samples
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/git/refs/REF \
-d '{"sha":"aa218f56b14c9653891f9e74264a383fa43fefbd","force":true}'Response
Status: 200{
"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"
}
}Delete a reference
Parameters
| Headers |
|---|
| Nom, Type, Description |
acceptstringSetting to |
| Path parameters |
| Nom, Type, Description |
ownerstringRequiredThe account owner of the repository. The name is not case sensitive. |
repostringRequiredThe name of the repository. The name is not case sensitive. |
refstringRequiredref parameter |
HTTP response status codes
| Status code | Description |
|---|---|
204 | No Content |
422 | Validation failed, or the endpoint has been spammed. |
Code samples
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/git/refs/REFResponse
Status: 204