Azure为Azure DevOps提供了一个az repos
CLI,允许对存储库进行方便的编程管理。
然而,似乎没有明显的方法使用az repos
CLI来分叉一个存储库。
这里的预期使用模式是将目标存储库从给定的项目派生到相同Azure DevOps订阅中(可能)不同项目中的存储库。
一个可以从DevOps管道执行的解决方案在这里也是一个可用的解决方案。
有人管理这个吗?
你可以使用Rest API来创建一个分支。你需要使用存储库-创建Api,并在URL &正文添加源存储库:
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories?sourceRef={sourceRef}&api-version=6.0
例如:
POST https://dev.azure.com/{organization}/_apis/git/repositories?sourceRef=users/heads/master&api-version=6.0
身体:
{
"name": "forkRepositoryWithOnlySourceRef",
"project": {
"id": "3b046b6a-d070-4cd5-ad59-2eace5d05b90"
},
"parentRepository": {
"id": "76b510af-7910-4a96-9902-b978d6226bee"
}
}