브랜치 API

Tier: Free, Premium, Ultimate
Offering: GitLab.com, Self-Managed, GitLab Dedicated

이 API는 리포지터리 브랜치에서 작동합니다.

보호된 브랜치 API도 참조하십시오.

리포지터리 브랜치 디렉터리

프로젝트에서 이름순으로 정렬된 리포지터리 브랜치 디렉터리을 가져옵니다.

note
이 엔드포인트는 리포지터리가 공개적으로 접근 가능한 경우 인증 없이 액세스할 수 있습니다.
GET /projects/:id/repository/branches

Parameters:

속성 유형 필수 설명
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"
    }
  },
  ...
]

단일 리포지터리 브랜치 가져오기

단일 프로젝트 리포지터리 브랜치를 가져옵니다.

note
이 엔드포인트는 리포지터리가 공개적으로 접근 가능한 경우 인증 없이 액세스할 수 있습니다.
GET /projects/:id/repository/branches/:branch

Parameters:

속성 유형 필수 설명
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

Parameters:

속성 유형 필수 설명
id integer yes 인증된 사용자가 소유한 프로젝트의 ID 또는 URL-encoded path입니다.
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"
}

리포지터리 브랜치 삭제

리포지터리에서 브랜치를 삭제합니다.

note
에러가 발생하는 경우 설명 메시지가 제공됩니다.
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된 모든 브랜치를 삭제합니다.

note
이 작업의 일부로 보호된 브랜치는 삭제되지 않습니다.
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"

관련 주제