我正在尝试从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]"
考虑:
- 远端(Azure)不支持git archive
- git克隆工作
最明显的解决方法是执行git克隆—不签出,然后执行所需文件的git restore
。
或稀疏结帐:
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"