- 리포지터리 브랜치 디렉터리
 - 단일 리포지터리 브랜치 가져오기
 - 리포지터리 브랜치 보호
 - 리포지터리 브랜치 해제
 - 리포지터리 브랜치 생성
 - 리포지터리 브랜치 삭제
 - Merge된 브랜치 삭제
 - 관련 주제
 
브랜치 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으로 인코딩된 경로입니다. | 
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로 인코딩된 경로입니다. | 
branch
 | string | yes | 브랜치의 URL로 인코딩된 이름입니다. | 
예시 요청:
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
 | integer | yes | 인증된 사용자가 소유한 프로젝트의 ID 또는 URL로 인코딩된 경로입니다. | 
branch
 | string | yes | 브랜치 이름입니다. | 
ref
 | string | yes | 브랜치 이름 또는 브랜치를 만들기 위한 커밋 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
 | integer/string | yes | 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로입니다. | 
branch
 | string | yes | 브랜치의 이름입니다. | 
예시 요청:
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/branches/newbranch"
Merge된 브랜치 삭제
프로젝트의 기본 브랜치로 Merge된 모든 브랜치를 삭제합니다.
이 작업의 일부로 보호된 브랜치는 삭제되지 않습니다.
DELETE /projects/:id/repository/merged_branches
매개변수:
| 속성 | 타입 | 필수 | 설명 | 
|---|---|---|---|
id
 | integer/string | yes | 인증된 사용자가 소유한 프로젝트의 ID 또는 URL 인코딩된 경로입니다. | 
예시 요청:
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/merged_branches"
도움말