브랜치 API
이 API는 저장소 브랜치에서 작동합니다.
또한 보호된 브랜치 API를 참조하세요.
저장소 브랜치 목록
프로젝트의 저장소 브랜치 목록을 가져오며, 이름순으로 알파벳 정렬됩니다.
GET /projects/:id/repository/branches
매개변수:
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id |
정수 또는 문자열 | 예 | 프로젝트의 ID 또는 URL 인코딩된 경로. |
search |
문자열 | 아니오 | 검색 문자열이 포함된 브랜치 목록을 반환합니다. ^term 을 사용하여 term 으로 시작하는 브랜치를 찾고, term$ 을 사용하여 term 으로 끝나는 브랜치를 찾습니다. |
regex |
문자열 | 아니오 | re2 정규 표현식과 일치하는 이름을 가진 브랜치 목록을 반환합니다. |
예제 요청:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "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 |
정수 또는 문자열 | 예 | 프로젝트의 ID 또는 URL 인코딩된 경로. |
branch |
문자열 | 예 | 브랜치의 URL 인코딩된 이름. |
예제 요청:
curl --header "PRIVATE-TOKEN: <your_access_token>" \
--url "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 |
integer | 예 | 프로젝트의 ID 또는 URL 인코딩된 경로. |
branch |
string | 예 | 브랜치의 이름. |
ref |
string | 예 | 브랜치 이름 또는 브랜치를 생성할 커밋 SHA. |
예제 요청:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
--url "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 |
integer/string | 예 | 프로젝트의 ID 또는 URL 인코딩된 경로. |
branch |
string | 예 | 브랜치의 이름. |
예제 요청:
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" \
--url "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>" \
--url "https://gitlab.example.com/api/v4/projects/5/repository/merged_branches"