简体   繁体   English

GIT智能HTTP协议的服务器端和客户端之间有什么细节区别

[英]What details difference between server side and client of GIT smart HTTP protocol

I hope someone will have answered the details difference between server side and client side of GIT smart HTTP protocol. 我希望有人能够回答GIT智能HTTP协议的服务器端和客户端之间的细节差异。

Best way is provide some references book & code for advance. 最好的方法是提供一些推荐的参考书和代码。


Some people said, 有人说,

libgit2 already exposes a packbuilder. libgit2已经公开了一个packbuilder。 However, you'll have to implement the server-side protocol by yourself. 但是,您必须自己实现服务器端协议。

reference to this link 参考此链接

Can we implement the server side with libgit2sharp(or libgit2) with small code? 我们可以用libgit2sharp(或libgit2)用小代码实现服务器端吗?


Following the question above. 按照上面的问题。 We can dealing with pack with git.exe receive-pack and git.exe upload-pack command with --stateless-rpc argument. 我们可以使用--stateless-rpc参数处理包含git.exe receive-packgit.exe upload-pack命令git.exe upload-pack The implemented code are here and here . 实现的代码在这里这里

Can we compile above codes as native code into .Net assembly? 我们可以将上面的代码编译为.Net程序集中的本机代码吗? Even though we can connect ASP.NET stream and git.exe by pipeline, but it is not a good way. 即使我们可以通过管道连接ASP.NET流和git.exe,但这不是一个好方法。

If you are just looking for a .NET library for interacting with GIT try GitSharp or nGit . 如果您只是在寻找与GIT交互的.NET库,请尝试使用GitSharpnGit The source code for GitSharp may also be useful since you appear to be ac# developer and GitSharp is not an automated port. GitSharp源代码也可能很有用,因为您似乎是ac#developer而GitSharp不是自动端口。 Otherwise: 除此以外:

(as the comments above show), there isn't a whole lot of easy to find documentation on this protocol. (如上面的评论所示),这个协议上没有很多很容易找到的文档。 Fortunately, Git makes reverse engineering the protocol easy and shouldn't be too difficult. 幸运的是,Git使协议的逆向工程变得容易,并且不应该太困难。

The newer Smart-Git protocol now adds another parameter to the GET http request that Older servers will ignore (older than 1.6.6) and will cause newer servers to switch to a multi post mode. 较新的Smart-Git协议现在为旧服务器将忽略的GET http请求添加了另一个参数(早于1.6.6),并将导致更新的服务器切换到多帖模式。 The newer server at this point build a custom packfile for the client containing only the files the client needs. 此时较新的服务器为客户端构建自定义包文件,仅包含客户端所需的文件。

In order to reverse engineer exactly what happens during the protocol portion you can use the environment variable: 为了对协议部分期间发生的事情进行反向工程,您可以使用环境变量:

SET GIT_CURL_VERBOSE=1

With this enabled, Git will output the HTTP requests and headers for each call that it makes, and will also output the HTTP status code and response headers for each response. 启用此功能后,Git将为其发出的每个调用输出HTTP请求和标头,并且还将为每个响应输出HTTP状态代码和响应标头。 You can also use a tool like Fiddler to see all of the http traffic that is occurring. 您还可以使用Fiddler之类的工具查看正在发生的所有http流量。 In order to do this you will have to use a second Git environment variable to force GIT to go through the http proxy: 为此,您必须使用第二个Git环境变量来强制GIT通过http代理:

SET HTTP_PROXY=http://localhost:8888

At this point you basically start issuing Git commands and monitoring the http traffic. 此时,您基本上开始发出Git命令并监控http流量。

For instance executing "git push -u origin master" 例如执行“git push -u origin master”

returns: 收益:

GET http://localhost:8000/gitserver/git/info/refs?service=git-receive-pack

This blog entry has a decent example of the described methodology above. 此博客条目具有上述所述方法的一个很好的例子。

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

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