Warm tip: This article is reproduced from serverfault.com, please click

azure-有没有一种方法可以使用AZ CLI扩展来查询与GIT存储库关联的所有分支?

(azure - Is there a way to query all branches associated with a GIT repository using AZ CLI extensions?)

发布于 2020-12-14 17:06:29

我正在尝试编写条件来检查git repo是否具有特定分支。如果不是,则创建该分支。

我知道可以通过命令行使用以下命令来实现此目的:

git branch
git checkout etc..

但是我想知道是否有任何Azure命令行扩展可以做到这一点?

Questioner
user9900698
Viewed
0
Shamrai Aleksander 2020-12-15 02:03:33

你可以尝试az repos ref list使用过滤器选项来搜索“ heads / your_path”之类的分支(其余API文档上的示例

例子:

az devops login --org "https://dev.azure.com/<your_org>"
Token:

az repos ref list --org "https://dev.azure.com/your_org" -p TeamProject -r RepoName --filter heads/

[
  {
    "creator": {
      "descriptor": "------",
      "directoryAlias": null,
      "displayName": "------",
      "id": "0f98bf70-30c3----",
      "imageUrl": "----",
      "inactive": null,
      "isAadIdentity": null,
      "isContainer": null,
      "isDeletedInOrigin": null,
      "profileUrl": null,
      "uniqueName": "-------",
      "url": "-------"
    },
    "isLocked": null,
    "isLockedBy": null,
    "name": "refs/heads/dev",
    "objectId": "4734085d73703e88ae39-----",
    "peeledObjectId": null,
    "statuses": null,
    "url": "-----"
  },