Sly
Sly

Reputation: 15247

git archive fatal: Operation not supported by protocol

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.

Upvotes: 41

Views: 29981

Answers (4)

petee
petee

Reputation: 111

As @VonC mentioned, support for git archive over HTTP was added in Git v2.44.0 (released February 22, 2024).

Before Git v2.44.0, you'll see this error when you try it:

fatal: operation not supported by protocol

From Git v2.44.0 onward, you should succeed, but only if the server supports it. If not, you will see:

error: RPC failed; HTTP 404 curl 22 The requested URL returned error: 404
fatal: git archive: expected ACK/NAK, got a flush packet

I checked GitHub, GitLab, Bitbucket, and GerritHub a week or two ago, and none of them supported this option yet. I guess it's still too early.

Upvotes: 0

VonC
VonC

Reputation: 1329712

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:

Upvotes: 4

J-16 SDiZ
J-16 SDiZ

Reputation: 26930

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.

Upvotes: 15

user4931107
user4931107

Reputation: 117

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

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

Upvotes: 10

Related Questions