问题描述
但是如果我运行这个:
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]"
解决方法
考虑:
- 远程端 (Azure) 不支持 git archive
- 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
,
我能够使用这种方法从文件中提取数据:
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"