1

I am trying to pull a single file from an Azure Git repo.

But if I run this: git archive --remote="ssh.dev.azure.com:v3/[organization]/[project]/[repo]" master myfile

It returns an error:

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

This happens in both Linux and Windows.

On the other hand, note that these work fine:

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

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

twasbrillig
  • 17,084
  • 9
  • 43
  • 67
  • 1
    `git archive` relies on the archive-creating-program (`git-upload-archive`) being on the server. The other two rely on the Git-commit-sending-program (`git-upload-pack`) being on the server. Obviously this server only has the second program, not the first. (Probably it has the third program, `git-send-pack`, as well, to allow `git push`.) – torek Jan 27 '21 at 06:30

2 Answers2

1

Considering:

  • the remote side (Azure) does not support git archive
  • the git clone works

the obvious workaround becomes doing a git clone --no-checkout, followed by a git restore of just the file you need.
Or a 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

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

I was able to pull data from a file with this method:

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"

twasbrillig
  • 17,084
  • 9
  • 43
  • 67