Git归档致命错误:协议不支持该操作。

39

我正在尝试从远程 Git 仓库中提取部分内容。正如这里所推荐的那样,使用以下命令帮助实现:

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

但我收到了错误消息:

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

Git不支持通过http协议进行此操作吗?这是托管环境还是git本身的问题?任何指导都将有所帮助,谢谢。

2个回答

16

git archive 可以与具有Git协议支持的服务器一起使用(即Git服务器,智能 HTTP 和 SSH 服务器)。

在您的情况下,要么是您的 Git 版本太旧,要么是服务器是普通的 HTTP 服务器(没有 "智能" Git 支持)。您需要从那里克隆存储库并进行归档。


我们的 Git 服务器使用智能 HTTP,还能是什么呢? - Sly
1
根据协议描述,智能HTTP也被排除在外:https://github.com/git/git/blob/master/Documentation/technical/http-protocol.txt - max630

11

你不能使用http协议来实现git版本控制,只能使用git协议。例如:

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

3
你有支持这个主张的来源吗? - Phil
我似乎在所有情况下都无法使用git协议。例如,有一个名为https://github.com/tesseract-ocr/tessdata的repo。我可以将其克隆为git://github.com/tesseract-ocr/tessdata.git,因此URL是正确的。但是,如果我尝试“git archive --remote = git://github.com/tesseract-ocr/tessdata.git 4.0.0 eng.traineddata”,它会显示“fatal:The remote end hung up unexpectedly”。你知道是什么原因吗? - Alexander Samoylov
1
找到了:https://dev59.com/Uovda4cB1Zd3GeqPcKUY。这在GitHub上根本不起作用。 - Alexander Samoylov

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接