简体   繁体   中英

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.

Let's say your Git repository is located here http://gitserver.com/gitrepo .

When you do Git clone over HTTP protocol git clone http://gitserver.com/gitrepo , client accesses these URLs:

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 ). 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. As Git SCM chapter "Smart HTTP Transport" states:

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.

In addition, you can find the dumb and smart protocols described in detail in Pro-Git book, chapter 9, section " Transfer Protocol " .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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