브랜치 API
Tier: Free, Premium, Ultimate
Offering: GitLab.com, Self-managed, GitLab Dedicated
이 API는 저장소 브랜치에서 작동합니다.
보호된 브랜치 API도 참조하세요.
저장소 브랜치 목록
프로젝트의 저장소 브랜치 목록을 이름 알파벳순으로 정렬하여 가져옵니다.
참고: 이 엔드포인트는 저장소가 공개적으로 접근 가능한 경우 인증 없이 액세스할 수 있습니다.
GET /projects/:id/repository/branches
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id
| integer/string | yes | 인증된 사용자가 소유한 프로젝트의 ID 또는 URL-encoded path를 사용합니다. |
search
| string | no | 검색 문자열을 포함하는 브랜치 목록을 반환합니다. ^term 을 사용하여 term 으로 시작하는 브랜치를 찾고, term$ 을 사용하여 term 으로 끝나는 브랜치를 찾을 수 있습니다.
|
regex
| string | no | re2 정규 표현식과 일치하는 이름을 가진 브랜치 목록을 반환합니다. |
예시 요청:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/branches"
예시 응답:
[
{
"name": "main",
"merged": false,
"protected": true,
"default": true,
"developers_can_push": false,
"developers_can_merge": false,
"can_push": true,
"web_url": "https://gitlab.example.com/my-group/my-project/-/tree/main",
"commit": {
"id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
"short_id": "7b5c3cc",
"created_at": "2012-06-28T03:44:20-07:00",
"parent_ids": [
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
],
"title": "add projects API",
"message": "add projects API",
"author_name": "John Smith",
"author_email": "john@example.com",
"authored_date": "2012-06-27T05:51:39-07:00",
"committer_name": "John Smith",
"committer_email": "john@example.com",
"committed_date": "2012-06-28T03:44:20-07:00",
"trailers": {},
"web_url": "https://gitlab.example.com/my-group/my-project/-/commit/7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
}
},
...
]
단일 저장소 브랜치 가져오기
단일 프로젝트 저장소 브랜치를 가져옵니다.
참고: 이 엔드포인트는 저장소가 공개적으로 접근 가능한 경우 인증 없이 액세스할 수 있습니다.
GET /projects/:id/repository/branches/:branch
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id
| integer/string | yes | 인증된 사용자가 소유한 프로젝트의 ID 또는 URL-encoded path를 사용합니다. |
branch
| string | yes | 브랜치의 URL-encoded name을 사용합니다. |
예시 요청:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/branches/main"
예시 응답:
{
"name": "main",
"merged": false,
"protected": true,
"default": true,
"developers_can_push": false,
"developers_can_merge": false,
"can_push": true,
"web_url": "https://gitlab.example.com/my-group/my-project/-/tree/main",
"commit": {
"id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
"short_id": "7b5c3cc",
"created_at": "2012-06-28T03:44:20-07:00",
"parent_ids": [
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
],
"title": "add projects API",
"message": "add projects API",
"author_name": "John Smith",
"author_email": "john@example.com",
"authored_date": "2012-06-27T05:51:39-07:00",
"committer_name": "John Smith",
"committer_email": "john@example.com",
"committed_date": "2012-06-28T03:44:20-07:00",
"trailers": {},
"web_url": "https://gitlab.example.com/my-group/my-project/-/commit/7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
}
}
저장소 브랜치 보호
저장소 브랜치 보호에 대한 정보는 POST /projects/:id/protected_branches
를 참조하세요.
저장소 브랜치 보호 해제
저장소 브랜치의 보호 해제에 대한 정보는 DELETE /projects/:id/protected_branches/:name
를 참조하세요.
저장소 브랜치 생성
저장소에 새로운 브랜치를 생성합니다.
POST /projects/:id/repository/branches
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id
| 정수 | 예 | 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로 |
branch
| 문자열 | 예 | 브랜치 이름 |
ref
| 문자열 | 예 | 브랜치 이름 또는 브랜치를 생성할 커밋 SHA |
예시 요청:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/branches?branch=newbranch&ref=main"
예시 응답:
{
"commit": {
"id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
"short_id": "7b5c3cc",
"created_at": "2012-06-28T03:44:20-07:00",
"parent_ids": [
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
],
"title": "add projects API",
"message": "add projects API",
"author_name": "John Smith",
"author_email": "john@example.com",
"authored_date": "2012-06-27T05:51:39-07:00",
"committer_name": "John Smith",
"committer_email": "john@example.com",
"committed_date": "2012-06-28T03:44:20-07:00",
"trailers": {},
"web_url": "https://gitlab.example.com/my-group/my-project/-/commit/7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
},
"name": "newbranch",
"merged": false,
"protected": false,
"default": false,
"developers_can_push": false,
"developers_can_merge": false,
"can_push": true,
"web_url": "https://gitlab.example.com/my-group/my-project/-/tree/newbranch"
}
저장소 브랜치 삭제
저장소에서 브랜치를 삭제합니다.
참고: 오류 발생 시 설명 메시지가 제공됩니다.
DELETE /projects/:id/repository/branches/:branch
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id
| 정수/문자열 | 예 | 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로 |
예시 요청:
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/branches/newbranch"
병합된 브랜치 삭제
프로젝트의 기본 브랜치로 병합된 모든 브랜치를 삭제합니다.
참고: 이 작업은 보호된 브랜치는 삭제되지 않습니다.
DELETE /projects/:id/repository/merged_branches
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id
| 정수/문자열 | 예 | 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로 |
예시 요청:
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/merged_branches"