Branches API

Branches API

该 API 在存储库分支上运行 .

提示:另请参阅 .

从项目中获取存储库分支的列表,按名称的字母顺序排序.

注意:如果可公开访问该存储库,则无需身份验证即可访问此端点.

Parameters:

请求示例:

    响应示例:

    1. [ { "name": "master", "merged": false, "protected": true, "default": true, "developers_can_push": false, "developers_can_merge": false, "can_push": true, "web_url": "http://gitlab.example.com/my-group/my-project/-/tree/master", "commit": { "author_email": "john@example.com", "author_name": "John Smith", "authored_date": "2012-06-27T05:51:39-07:00", "committed_date": "2012-06-28T03:44:20-07:00", "committer_email": "john@example.com", "committer_name": "John Smith", "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", "short_id": "7b5c3cc", "title": "add projects API", "message": "add projects API", "parent_ids": [ "4ad91d3c1144c406e50c7b33bae684bd6837faf8" ] } }, ... ]

    Get single repository branch

    获取单个项目存储库分支.

    1. GET /projects/:id/repository/branches/:branch

    Parameters:

    请求示例:

    响应示例:

    1. { "name": "master", "merged": false, "protected": true, "default": true, "developers_can_push": false, "developers_can_merge": false, "can_push": true, "web_url": "http://gitlab.example.com/my-group/my-project/-/tree/master", "commit": { "author_email": "john@example.com", "author_name": "John Smith", "authored_date": "2012-06-27T05:51:39-07:00", "committed_date": "2012-06-28T03:44:20-07:00", "committer_email": "john@example.com", "committer_name": "John Smith", "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", "short_id": "7b5c3cc", "title": "add projects API", "message": "add projects API", "parent_ids": [ "4ad91d3c1144c406e50c7b33bae684bd6837faf8" ] } }

    有关保护存储库分支的信息,请参见 .

    Unprotect repository branch

    有关取消保护存储库分支的信息,请参见 .

    在存储库中创建一个新分支.

    1. POST /projects/:id/repository/branches

    Parameters:

    请求示例:

    1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/branches?branch=newbranch&ref=master"

    Delete repository branch

    从存储库中删除一个分支.

    注意:如果发生错误,将提供说明消息.

    1. DELETE /projects/:id/repository/branches/:branch

    Parameters:

    请求示例:

    1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/branches/newbranch"

    Will delete all branches that are merged into the project’s default branch.

    注意:此操作不会删除 .

      Parameters:

      请求示例: