【问题标题】:Forking a repository using the Azure az repos CLI使用 Azure az repos CLI 派生存储库
【发布时间】:2021-07-28 13:09:22
【问题描述】:

Azure 为 Azure DevOps 提供了一个az repos CLI,允许对存储库进行方便的编程管理。

但是,使用az repos CLI 似乎没有明显的方法来fork a repository

此处的预期使用模式是将目标存储库从给定项目派生到同一 Azure DevOps 订阅中(可能)不同项目中的存储库。

可以从 DevOps 管道执行的解决方案在这里也是可用的解决方案。

有人处理过这个吗?

【问题讨论】:

    标签: azure-devops azure-pipelines azure-devops-rest-api azure-cli


    【解决方案1】:

    您可以使用 Rest API 创建分叉。您需要使用Repositories - Create Api,并在 URL & Body 中添加源代码库:

    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"
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-06-13
      • 2021-02-11
      • 2020-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-24
      • 1970-01-01
      相关资源
      最近更新 更多