git archive fatal: Operation not supported by protocol
Asked Answered
L

3

40

I'm trying to checkout part of remote git repository. As recommended here, with help of command

git archive --format=zip --remote=http://path_to_repository

But I'm getting error message:

fatal: Operation not supported by protocol.
Unexpected end of command stream

Git is not supporting this operation with http protocol? Thats a problem of hosting environment or git itself? Any directions would help, thanks.

Lunula answered 29/6, 2012 at 8:41 Comment(0)
P
15

git archive can work with a server with git protocol support (i.e. git server, smart-http and ssh server).

In your case, either your git is too old, or the server is dumb http server (normal http server, without "smart" git support). You need to clone the repository and archive from there.

Plott answered 29/6, 2012 at 8:47 Comment(2)
Smart HTTP is used by our git server... What else could it be?Lunula
according to protocol description smart http is excluded as well: github.com/git/git/blob/master/Documentation/technical/…Hod
R
10

you can't use git achieve with http! only git protocol. i.e.

git archive --format=zip --remote=git://path_to_repository
Rubberneck answered 23/5, 2015 at 4:14 Comment(3)
Do you have any sources to back up this claim?Thorndike
I seems not working with git protocol in all cases. For example, there is a repo github.com/tesseract-ocr/tessdata. I can clone it as git://github.com/tesseract-ocr/tessdata.git thus the URL is correct. However if I try "git archive --remote=git://github.com/tesseract-ocr/tessdata.git 4.0.0 eng.traineddata" it says "fatal: The remote end hung up unexpectedly". Do you have a clue what is the cause?Espalier
Found: stackoverflow.com/questions/30659758/…. This does not work at all with GitHub.Espalier
H
2

Git is not supporting this operation with http protocol?

It should, with Git 2.44 (Q1 2024... 12 years later), batch 12: "git archive --remote=<remote>"(man) learned to talk over the smart http (aka stateless) transport.

See commit 176cd68, commit 35d26e7, commit 24f275a, commit 5c85836, commit 23b7d59, commit 4a61faf (21 Jan 2024) by Jiang Xin (jiangxin).
(Merged by Junio C Hamano -- gitster -- in commit fa50e7a, 30 Jan 2024)

remote-curl: supports git-upload-archive service

Signed-off-by: Jiang Xin

Add new service (git-upload-archive) support in remote-curl, so we can support remote archive over HTTP/HTTPS protocols.
Differences between git-upload-archive(man) and other services:

  1. The git-archive(man) program does not expect to see protocol version and capabilities when connecting to remote-helper, so do not send them in remote-curl for the git-upload-archive service.
  2. We need to detect protocol version by calling discover_refs().
    Fallback to use the git-upload-pack(man) service (which, like git-upload-archive, is a read-only operation) to discover protocol version.

And:

transport-helper: protocol v2 supports upload-archive

Signed-off-by: Jiang Xin

We used to support only git-upload-pack(man) service for protocol v2.
In order to support remote archive over HTTP/HTTPS protocols, add new service support for git-upload-archive(man) in protocol v2.

And:

Honduras answered 3/3 at 0:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.