简体   繁体   English

通过HTTP的Git克隆

[英]Git clone over HTTP

I am interested in step by step workflow that a Git client does when you execute clone command over HTTP protocol. 我对通过HTTP协议执行clone命令时Git客户端执行的分步工作流感兴趣。

Let's say your Git repository is located here http://gitserver.com/gitrepo . 假设您的Git存储库位于http://gitserver.com/gitrepo

When you do Git clone over HTTP protocol git clone http://gitserver.com/gitrepo , client accesses these URLs: 当您通过HTTP协议进行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

Why does it do those requests? 为什么要提出这些要求? What does it do next? 接下来会做什么? How does it get a full list of files in repository? 如何获取存储库中文件的完整列表?

Old versions of git did not support the " Smart HTTP protocol " (like the ones used in ssh and git ). git的旧版本不支持“ 智能HTTP协议 ”(例如sshgit使用的协议 )。 So, sending a GET and then a POST (depending of the results of GET ) is an elegant way to keep support for both, old and new one. 因此,先发送一个GET ,然后发送一个POST (取决于GET的结果)是保持对旧的和新的支持的一种优雅方法。 As Git SCM chapter "Smart HTTP Transport" states: Git SCM章节“智能HTTP传输”所述:

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. 新的客户端现在将发送带有额外GET参数的请求,旧服务器将简单地忽略该请求,但是运行智能CGI的服务器将识别并切换到类似于git协议上进行的对话的multi-POST模式。 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. 完成这一系列的POST之后,服务器便知道客户端需要哪些对象,并可以构建自定义的packfile并将其流回。

In addition, you can find the dumb and smart protocols described in detail in Pro-Git book, chapter 9, section " Transfer Protocol " . 另外,您可以在Pro-Git书的第9章“ 传输协议 ”部分中找到详细描述的哑协议和智能协议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM