Skip to main content
설명서에 자주 업데이트를 게시하며 이 페이지의 번역이 계속 진행 중일 수 있습니다. 최신 정보는 영어 설명서를 참조하세요.
GitHub AE는 현재 제한된 릴리스에 있습니다.

Git 참조

REST API를 사용하여 GitHub AE에서 Git 데이터베이스의 참조와 상호 작용

Git 참조 정보

Git 참조(git ref)는 Git 커밋 SHA-1 해시를 포함하는 파일입니다. Git 커밋을 참조할 때 해시가 아닌 기억하기 쉬운 이름을 나타내는 Git 참조를 사용할 수 있습니다. 새 커밋을 가리키도록 Git 참조를 다시 작성할 수 있습니다. 분기는 새 Git 커밋 해시를 저장하는 Git 참조입니다. 이러한 엔드포인트를 사용하면 GitHub AE에서 Git 데이터베이스에 참조를 읽고 쓸 수 있습니다.

List matching references

에서 작동 GitHub Apps

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.

매개 변수

헤더
이름, 형식, 설명
acceptstring

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, 형식, 설명
ownerstring필수

The account owner of the repository. The name is not case sensitive.

repostring필수

The name of the repository. The name is not case sensitive.

refstring필수

ref parameter

HTTP 응답 상태 코드

상태 코드Description
200

OK

코드 샘플

get/repos/{owner}/{repo}/git/matching-refs/{ref}
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/git/matching-refs/REF

Response

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

에서 작동 GitHub Apps

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".

매개 변수

헤더
이름, 형식, 설명
acceptstring

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, 형식, 설명
ownerstring필수

The account owner of the repository. The name is not case sensitive.

repostring필수

The name of the repository. The name is not case sensitive.

refstring필수

ref parameter

HTTP 응답 상태 코드

상태 코드Description
200

OK

404

Resource not found

코드 샘플

get/repos/{owner}/{repo}/git/ref/{ref}
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/git/ref/REF

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" } }

Create a reference

에서 작동 GitHub Apps

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.

매개 변수

헤더
이름, 형식, 설명
acceptstring

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, 형식, 설명
ownerstring필수

The account owner of the repository. The name is not case sensitive.

repostring필수

The name of the repository. The name is not case sensitive.

본문 매개 변수
이름, 형식, 설명
refstring필수

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.

shastring필수

The SHA1 value for this reference.

keystring

HTTP 응답 상태 코드

상태 코드Description
201

Created

422

Validation failed, or the endpoint has been spammed.

코드 샘플

post/repos/{owner}/{repo}/git/refs
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

에서 작동 GitHub Apps

매개 변수

헤더
이름, 형식, 설명
acceptstring

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, 형식, 설명
ownerstring필수

The account owner of the repository. The name is not case sensitive.

repostring필수

The name of the repository. The name is not case sensitive.

refstring필수

The name of the fully qualified reference to update. For example, refs/heads/master. If the value doesn't start with refs and have at least two slashes, it will be rejected.

본문 매개 변수
이름, 형식, 설명
shastring필수

The SHA1 value to set this reference to

forceboolean

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.

기본값: false

HTTP 응답 상태 코드

상태 코드Description
200

OK

422

Validation failed, or the endpoint has been spammed.

코드 샘플

patch/repos/{owner}/{repo}/git/refs/{ref}
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

에서 작동 GitHub Apps

매개 변수

헤더
이름, 형식, 설명
acceptstring

Setting to application/vnd.github+json is recommended.

경로 매개 변수
이름, 형식, 설명
ownerstring필수

The account owner of the repository. The name is not case sensitive.

repostring필수

The name of the repository. The name is not case sensitive.

refstring필수

ref parameter

HTTP 응답 상태 코드

상태 코드Description
204

No Content

422

Validation failed, or the endpoint has been spammed.

코드 샘플

delete/repos/{owner}/{repo}/git/refs/{ref}
curl \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/git/refs/REF

Response

Status: 204