安装

依赖安装

[root@cloud-master ~]# yum -y install gcc openssl-devel expat-devel libcurl-devel

下载源码包

官方最新git源码地址

[root@cloud-master ~]# wget https://github.com/git/git/archive/refs/tags/v2.31.7.tar.gz
[root@cloud-master ~]# tar zxf v2.31.7.tar.gz 
[root@cloud-master ~]# cd git-2.31.7/

编译安装

[root@cloud-master git-2.31.7]# make all
[root@cloud-master git-2.31.7]# make install

验证

[root@cloud-master git-2.31.7]# git --version
git version 2.31.7

遇到的错误

缺少openssl/ssl.h

[root@cloud-master git-2.31.7]# make all
make: curl-config: Command not found
    CC fuzz-commit-graph.o
In file included from commit-graph.h:4:0,
                 from fuzz-commit-graph.c:1:
git-compat-util.h:303:25: fatal error: openssl/ssl.h: No such file or directory
 #include <openssl/ssl.h>
                         ^
compilation terminated.
make: *** [fuzz-commit-graph.o] Error 1

解决办法

[root@cloud-master git-2.31.7]# yum -y install openssl-devel

缺少curl依赖

In file included from http.c:2:0:
http.h:6:23: fatal error: curl/curl.h: No such file or directory
 #include <curl/curl.h>
                       ^
compilation terminated.
make: *** [http.o] Error 1

解决办法

[root@cloud-master git-2.31.7]# yum -y install libcurl-devel

缺少expat依赖

CC http-walker.o
    CC http-fetch.o
    LINK git-http-fetch
    CC http-push.o
http-push.c:22:19: fatal error: expat.h: No such file or directory
 #include <expat.h>
                   ^
compilation terminated.
make: *** [http-push.o] Error 1

解决办法

[root@cloud-master git-2.31.7]# yum -y install expat-devel
END

本文标题:Centos7下源码编译安装git命令

本文作者:宇宙最帅的男人

本文链接:https://lolicp.com/linux/202308550.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归 (lolicp.com) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2023 年 04 月 08 日
如果觉得我的文章对你有用,请随意赞赏