gpt4 book ai didi

通过 HTTP 克隆 Git

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:08:38 25 4
gpt4 key购买 nike

我对 Git 客户端在通过 HTTP 协议(protocol)执行 clone 命令时执行的分步工作流很感兴趣。

假设您的 Git 存储库位于 http://gitserver.com/gitrepo

当您通过 HTTP 协议(protocol)执行 Git 克隆时 git clone http://gitserver.com/gitrepo,客户端访问这些 URL:

GET  http://gitserver.com/gitrepo/info/refs?service=git-upload-pack
POST http://gitserver.com/gitrepo/git-upload-pack

它为什么要执行这些请求?它接下来做什么?它如何获得存储库中文件的完整列表?

最佳答案

旧版本的 git 不支持“智能 HTTP 协议(protocol)”(比如 sshgit 中使用的协议(protocol))。因此,发送一个 GET 然后发送一个 POST(取决于 GET 的结果)是保持对旧版本和旧版本的支持的优雅方式新的一个。作为Git SCM chapter "Smart HTTP Transport"状态:

The new clients will now send a request with an extra GET parameter that older servers will simply ignore, but servers running the smart CGI will recognize and switch modes to a multi-POST mode that is similar to the conversation that happens over the git protocol. Once this series of POSTs is complete, the server knows what objects the client needs and can build a custom packfile and stream it back.

此外,您可以在 Pro-Git book, chapter 9, section "Transfer Protocol" 中找到详细描述的愚蠢和智能协议(protocol)。 .

关于通过 HTTP 克隆 Git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25954820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com