Repositories - Update
使用新的存储库名称或新的默认分支更新 Git 存储库。
PATCH https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}?api-version=7.1
URI 参数
| 名称 | 在 | 必需 | 类型 | 说明 |
|---|---|---|---|---|
|
organization
|
path | True |
string |
Azure DevOps 组织的名称。 |
|
repository
|
path | True |
string (uuid) |
存储库的 ID。 |
|
project
|
path |
string |
项目 ID 或项目名称 |
|
|
api-version
|
query | True |
string |
要使用的 API 版本。 这应设置为“7.1”才能使用此版本的 API。 |
请求正文
| 名称 | 类型 | 说明 |
|---|---|---|
| _links |
表示 REST 引用链接集合的类。 |
|
| defaultBranch |
string |
|
| id |
string (uuid) |
|
| isDisabled |
boolean |
如果禁用存储库,则为 True。 否则为 False。 |
| isFork |
boolean |
如此 如果存储库创建为分叉。 |
| isInMaintenance |
boolean |
如此 如果存储库处于维护状态。 否则为 False。 |
| name |
string |
|
| parentRepository | ||
| project |
表示对 TeamProject 的浅表引用。 |
|
| remoteUrl |
string |
|
| size |
integer (int64) |
存储库的压缩大小(字节)。 |
| sshUrl |
string |
|
| url |
string |
|
| validRemoteUrls |
string[] |
|
| webUrl |
string |
响应
| 名称 | 类型 | 说明 |
|---|---|---|
| 200 OK |
作成功。 响应包含更新的存储库信息。 |
安全性
oauth2
类型:
oauth2
流向:
accessCode
授权 URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
令牌 URL:
https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
作用域
| 名称 | 说明 |
|---|---|
| vso.code_manage | 授予读取、更新和删除源代码、访问有关提交、更改集、分支和其他版本控制项目的元数据的能力。 此外,还授予创建和管理代码存储库、创建和管理拉取请求和代码评审以及通过服务挂钩接收有关版本控制事件的通知的能力。 |
示例
| Disable repository |
| Update a respository while specifying the project |
| Update a respository without specifying the project |
Disable repository
示例请求
PATCH https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/git/repositories/5febef5a-833d-4e14-b9c0-14cb638f91e6?api-version=7.1
{
"isDisabled": true
}
示例响应
{
"id": "5febef5a-833d-4e14-b9c0-14cb638f91e6",
"name": "RenamedRepository",
"RenamedRepository": true,
"isDisabled": true,
"url": "https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/git/repositories/5febef5a-833d-4e14-b9c0-14cb638f91e6",
"project": {
"id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"name": "Fabrikam-Fiber-Git",
"url": "https://dev.azure.com/fabrikam/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"state": "wellFormed"
},
"defaultBranch": "refs/heads/live",
"remoteUrl": "https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_git/RenamedRepository",
"type": "normal"
}
Update a respository while specifying the project
示例请求
PATCH https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/git/repositories/5febef5a-833d-4e14-b9c0-14cb638f91e6?api-version=7.1
{
"name": "RenamedRepository",
"defaultBranch": "refs/heads/live"
}
示例响应
{
"id": "5febef5a-833d-4e14-b9c0-14cb638f91e6",
"name": "RenamedRepository",
"isDisabled": false,
"url": "https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/git/repositories/5febef5a-833d-4e14-b9c0-14cb638f91e6",
"project": {
"id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"name": "Fabrikam-Fiber-Git",
"url": "https://dev.azure.com/fabrikam/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"state": "wellFormed"
},
"defaultBranch": "refs/heads/live",
"remoteUrl": "https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_git/RenamedRepository",
"type": "normal"
}
Update a respository without specifying the project
示例请求
PATCH https://dev.azure.com/fabrikam/_apis/git/repositories/5febef5a-833d-4e14-b9c0-14cb638f91e6?api-version=7.1
{
"name": "RenamedRepository",
"defaultBranch": "refs/heads/live"
}
示例响应
{
"id": "5febef5a-833d-4e14-b9c0-14cb638f91e6",
"name": "RenamedRepository",
"isDisabled": false,
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/5febef5a-833d-4e14-b9c0-14cb638f91e6",
"project": {
"id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"name": "Fabrikam-Fiber-Git",
"url": "https://dev.azure.com/fabrikam/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"state": "wellFormed"
},
"defaultBranch": "refs/heads/live",
"remoteUrl": "https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_git/RenamedRepository",
"type": "normal"
}
定义
| 名称 | 说明 |
|---|---|
|
Git |
|
|
Git |
|
|
Project |
项目状态。 |
|
Project |
项目可见性。 |
|
Reference |
表示 REST 引用链接集合的类。 |
|
Team |
TeamProjectCollection 的引用对象。 |
|
Team |
表示对 TeamProject 的浅表引用。 |
GitRepository
| 名称 | 类型 | 说明 |
|---|---|---|
| _links |
表示 REST 引用链接集合的类。 |
|
| defaultBranch |
string |
|
| id |
string (uuid) |
|
| isDisabled |
boolean |
如果禁用存储库,则为 True。 否则为 False。 |
| isFork |
boolean |
如此 如果存储库创建为分叉。 |
| isInMaintenance |
boolean |
如此 如果存储库处于维护状态。 否则为 False。 |
| name |
string |
|
| parentRepository | ||
| project |
表示对 TeamProject 的浅表引用。 |
|
| remoteUrl |
string |
|
| size |
integer (int64) |
存储库的压缩大小(字节)。 |
| sshUrl |
string |
|
| url |
string |
|
| validRemoteUrls |
string[] |
|
| webUrl |
string |
GitRepositoryRef
| 名称 | 类型 | 说明 |
|---|---|---|
| collection |
此分支所在的团队项目集合 |
|
| id |
string (uuid) |
|
| isFork |
boolean |
如此 如果存储库创建为分叉 |
| name |
string |
|
| project |
表示对 TeamProject 的浅表引用。 |
|
| remoteUrl |
string |
|
| sshUrl |
string |
|
| url |
string |
ProjectState
项目状态。
| 值 | 说明 |
|---|---|
| all |
所有项目,无论状态如何,都已删除。 |
| createPending |
项目已排队创建,但该过程尚未启动。 |
| deleted |
项目已被删除。 |
| deleting |
项目正在删除。 |
| new |
正在创建项目。 |
| unchanged |
项目尚未更改。 |
| wellFormed |
项目已完全创建并可供使用。 |
ProjectVisibility
项目可见性。
| 值 | 说明 |
|---|---|
| private |
只有具有显式访问权限的用户才能看到该项目。 |
| public |
项目对所有人可见。 |
ReferenceLinks
表示 REST 引用链接集合的类。
| 名称 | 类型 | 说明 |
|---|---|---|
| links |
object |
链接的只读视图。 由于引用链接是只读的,因此我们只想将其公开为只读链接。 |
TeamProjectCollectionReference
TeamProjectCollection 的引用对象。
| 名称 | 类型 | 说明 |
|---|---|---|
| avatarUrl |
string |
集合头像 URL。 |
| id |
string (uuid) |
集合 ID。 |
| name |
string |
集合名称。 |
| url |
string |
集合 REST URL。 |
TeamProjectReference
表示对 TeamProject 的浅表引用。
| 名称 | 类型 | 说明 |
|---|---|---|
| abbreviation |
string |
项目缩写。 |
| defaultTeamImageUrl |
string |
指向默认团队标识映像的 URL。 |
| description |
string |
项目的说明(如果有)。 |
| id |
string (uuid) |
项目标识符。 |
| lastUpdateTime |
string (date-time) |
上次更新时间的项目。 |
| name |
string |
项目名称。 |
| revision |
integer (int64) |
项目修订。 |
| state |
项目状态。 |
|
| url |
string |
指向对象完整版本的 URL。 |
| visibility |
项目可见性。 |