【问题标题】:Running "git archive" in Azure Git gives error message在 Azure Git 中运行“git archive”会给出错误消息
【发布时间】:2021-04-30 21:34:39
【问题描述】:

我正在尝试从 Azure Git 存储库中提取单个文件。

但是如果我运行这个: git archive --remote="ssh.dev.azure.com:v3/[organization]/[project]/[repo]" master myfile

它返回一个错误:

remote: Could not find a Command Extension for Command:git-upload-archive
fatal: the remote end hung up unexpectedly

这在 Linux 和 Windows 中都会发生。

另一方面,请注意这些工作正常:

git clone "ssh.dev.azure.com:v3/[organization]/[project]/[repo]"

git ls-remote "ssh.dev.azure.com:v3/[organization]/[project]/[repo]"

【问题讨论】:

  • git archive 依赖于服务器上的存档创建程序 (git-upload-archive)。另外两个依赖于服务器上的 Git-commit-sending-program (git-upload-pack)。显然这个服务器只有第二个程序,而不是第一个。 (可能它还有第三个程序git-send-pack,以允许git push。)

标签: git azure archive


【解决方案1】:

考虑:

  • 远程端 (Azure) 不支持 git 存档
  • git clone 工作

显而易见的解决方法是执行git clone --no-checkout,然后是您需要的文件的git restore
sparse checkout:

git clone --filter=blob:none --sparse /url/repo
cd repo
git sparse-checkout init --cone

## or

git clone --filter=sparse:oid=shiny-app/.gitfilterspec` /url/repo
cd repo

# with .gitfilterspec including the file you need

【讨论】:

    【解决方案2】:

    我能够使用这种方法从文件中提取数据:

    curl -u ":[Personal Access Token]" "https://dev.azure.com/[organization]/[project]/_apis/sourceProviders/TfsGit/filecontents?repository=[repo]&path=[filepath]&commitOrBranch=[branch]&api-version=5.0-preview.1"

    【讨论】:

      猜你喜欢
      • 2014-10-01
      • 2011-04-12
      • 2021-07-04
      • 2019-01-20
      • 1970-01-01
      • 1970-01-01
      • 2010-12-08
      • 2017-04-11
      • 2021-11-23
      相关资源
      最近更新 更多