在 Linux 上安装 Git 向来仅需⼀⾏命令即可搞定,因为各式各样的包管理器帮了我们⼤忙,所以对于CentOS 系统来讲,直接执⾏如下命令即可安装:
yum install git当然通过这种⽅式安装的 Git 可能不是较新版的 Git
如果想安装较新版本的 Git ,则需要⾃⾏下载 Git 源码来编译安装。
可以使用 Wget 下载 Git 的源码包。当然,你也可以使用其他方式。
wget https://www.kernel.org/pub/software/scm/git/git-2.28.0.tar.gz如果你打算采用这种方式,并且你的操作系统中没有安装这个工具,那么你可以执行以下命令安装 Wget。
yum install --assumeyes wget我是在本地下载好的安装包,之后Xftp传上去的。
我这⾥选择安装的是 2.28.0 版,将下载好的安装包 git-2.28.0.tar.gz 直接放在了 root ⽬录下然后将其本地解压,得到 git-2.28.0 ⽬录:
[root@localhost ~]# tar -zxvf git-2.28.0.tar.gz进⼊到对应⽬录,执⾏配置、编译、安装命令即可,如下所示:
[root@localhost ~]# cd git-2.28.0/ [root@localhost git-2.28.0]# make configure [root@localhost git-2.28.0]# ./configure --prefix=/usr/local/git [root@localhost git-2.28.0]# make profix=/usr/local/git [root@localhost git-2.28.0]# make install将 Git 的可执⾏程序加⼊环境变量,便于后续使⽤ 编辑配置⽂件:
vim /etc/profile尾部加⼊ Git 的 bin 路径配置即可
export GIT_HOME=/usr/local/git export PATH=$PATH:$GIT_HOME/bin最后执⾏ source /etc/profile 使环境变量⽣效即可。
执⾏ git --version 查看安装后的版本即可
编译git时报错: zlib.h: No such file or directory Git:CentOS7安装git客户端,make: *** [configure] 错误 127