找出远程服务器上的git版本

时间:2014-11-04 15:12:20

标签: git

我在本地机器上寻找git命令,我可以运行它来查找在远程服务器上运行的git版本? 如果这是可能的话。

2 个答案:

答案 0 :(得分:21)

现代git服务器(从git 1.7.12.1开始)将在协议中的 capabilities 协商中返回其版本信息。虽然没有git命令可以在本地运行是准确的,但您只需查询git服务器以获取信息,最新版本将提供版本号。

您可以使用网络客户端请求:

<repository url>/info/refs?service=git-upload-pack

检查agent=报告的第一行。

例如,针对CodePlex:

% curl https://git01.codeplex.com/gittf/info/refs\?service=git-upload-pack
000000bd43569b9f6f29136b6544809eacd2417a308f9341 HEAD\0multi_ack thin-pack
side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed
no-done agent=git/1.8.4.msysgit.0

这表明CodePlex正在使用Git for Windows 1.8.4(git/1.8.4.msysgit.0)。

或者反对GitHub:

% curl https://github.com/libgit2/libgit2.git/info/refs\?service=git-upload-pack
000000f83f8d005a82b39c504220d65b6a6aa696c3b1a9c4 HEAD\0multi_ack
thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag
multi_ack_detailed no-done symref=HEAD:refs/heads/master
agent=git/2:2.1.1~peff-bare-reflogs-fetch-616-gc016f98
... ref information removed ...

表示GitHub正在使用自定义git版本:git/2:2.1.1~peff-bare-reflogs-fetch-616-gc016f98

答案 1 :(得分:0)

Edward Thomson建议的方式类似,您也可以使用environment debugging variables

GIT_TRACE_PACKET=true git ls-remote --heads https://github.com/libgit2/libgit2.git |& grep agent
12:31:40.317199 pkt-line.c:80           packet:          git< f92d495d44bff2bdb6fd99524a93986ea268c9e8 HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/github-g956b612bf136

同样,看起来GitHub正在使用Git的自定义构建:agent=git/github-g956b612bf136

相关问题