使用 GitHttpClient 在与 Azure DevOps 存储库中的默认主分支不同的分支中按路径检索项目

Retrieve item by path in a branch different than default master in Azure DevOps repository using GitHttpClient

我正在尝试使用 Microsoft.VisualStudio.Services.WebApi 包中的 GitHttpClient 与 Azure DevOps 中托管的存储库进行交互。我想知道 API 中是否有一种方法可以在与默认 master 分支不同的分支中按路径检索项目,因为我在方法 GetItemAsync 中找不到参数(或类似的 API 方法)在 GitHttpClient 下支持分支。

我还尝试将 DefaultBranch 更改为我要从中检索项目的分支,但 GetItemAsync 仍然从默认 master 分支检索项目。

repo.DefaultBranch = "my_intended_branch"; // does not change the behavior of GetItemAsync

有人知道如何从不同于默认主分支的分支中检索 GitItem 吗?

在此处找到解决方案:Microsoft Docs

基本上我需要做的是用分支名称创建一个 GitVersionDescriptor 对象,并将该对象传递给方法GetItemAsync(),它起作用了。