更新时间:2025-07-24 GMT+08:00
分享

分支重命名

功能介绍

分支重命名。

调试

您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。

URI

PUT /v4/repositories/{repository_id}/repository/branch

表1 路径参数

参数

是否必选

参数类型

描述

repository_id

Integer

参数解释:

仓库的ID,通过查询用户所有仓库接口查询项目列表获取。

约束限制:

不涉及。

取值范围:

1-2147483647

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

约束限制:

必传。

取值范围:

字符串长度不少于1,不超过10万。

默认取值:

不涉及。

表3 请求Body参数

参数

是否必选

参数类型

描述

new_branch

String

参数解释:

新分支名称。

约束限制:

不支持以 - . refs/heads/ refs/remotes/ 开头,不支持空格 [ \ < ~ ^ : ? * ! ( ) ' " | 等特殊字符,不支持以. / .lock结尾。

取值范围:

字符串长度不少于1,不超过200。

默认取值:

不涉及。

old_branch

String

参数解释:

基于分支名称。

约束限制:

不支持以 - . refs/heads/ refs/remotes/ 开头,不支持空格 [ \ < ~ ^ : ? * ! ( ) ' " | 等特殊字符,不支持以. / .lock结尾。

取值范围:

字符串长度不少于1,不超过200。

默认取值:

不涉及。

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

old_branch_name

String

参数解释:

旧分支名称。

约束限制:

不支持以 - . refs/heads/ refs/remotes/ 开头,不支持空格 [ \ < ~ ^ : ? * ! ( ) ' " | 等特殊字符,不支持以. / .lock结尾。

取值范围:

字符串长度不少于1,不超过200。

默认取值:

不涉及。

old_branch_commit_id

String

参数解释:

旧分支最新提交ID。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

new_branch_name

String

参数解释:

新分支名称。

约束限制:

不支持以 - . refs/heads/ refs/remotes/ 开头,不支持空格 [ \ < ~ ^ : ? * ! ( ) ' " | 等特殊字符,不支持以. / .lock结尾。

取值范围:

字符串长度不少于1,不超过200。

默认取值:

不涉及。

new_branch_commit_id

String

参数解释:

新分支最新提交ID。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

状态码:401

表5 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

error_msg

String

参数解释:

错误信息。

状态码:403

表6 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

error_msg

String

参数解释:

错误信息。

状态码:404

表7 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

error_msg

String

参数解释:

错误信息。

请求示例

PUT https://{endpoint}/v4/repositories/100000/repository/branch

{
  "new_branch" : "123",
  "old_branch" : "123test"
}

响应示例

状态码:200

OK

{
  "old_branch_name" : "123",
  "old_branch_commit_id" : "11526aa1624f5f173b85673010b4c249bb5756a5",
  "new_branch_name" : "123test",
  "new_branch_commit_id" : "11526aa1624f5f173b85673010b4c249bb5756a5"
}

状态码:401

Unauthorized

{
  "error_code" : "DEV.00000003",
  "error_msg" : "认证信息过期"
}

状态码:403

Bad Request

{
  "error_code" : "CH.004403",
  "error_msg" : "Insufficient permissions. Apply for the required permission and try again."
}

状态码:404

Not Found

{
  "error_code" : "CH.004404",
  "error_msg" : "Group Not Found"
}

状态码

状态码

描述

200

OK

401

Unauthorized

403

Bad Request

404

Not Found

错误码

请参见错误码

相关文档