Git是一个开源的分布式版本控制系统,可以有效、高速的处理从很小到非常大的项目版本管理。
本文记录了我在CentOS7下安装git的过程。
1、查看是否安装了git
输入命令git或者git --version
[root@VM_0_10_centos ~]# git
-bash: git: command not found
[root@VM_0_10_centos /]# git --version
-bash: git: command not found
都提示未安装git。
2、将linux目录切换到存放软件包的目录下
[root@VM_0_10_centos /]# cd /usr/src
3、下载git安装包
[root@VM_0_10_centos src]# wget https://www.kernel.org/pub/software/scm/git/git-2.19.0.tar.gz
4、解压git安装包
[root@VM_0_10_centos src]# tar -xzf git-2.19.0.tar.gz
在这里,参数-x表示解压此文件,-z表示用gzip来解压缩文件,-f后面立即接解压的文档名,不能再加参数。
执行解压缩命令后得到文件夹git-2.19.0。
5、配置git安装路径
[root@VM_0_10_centos src]# cd git-2.19.0
[root@VM_0_10_centos git-2.19.0]# ./configure prefix=/usr/local/git/
-Configure的-prefix选项是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr/local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr/local/share。
./configure prefix=/usr/local/git/指定了git的安装路径为/usr/local/git。
6、编译并安装
[root@VM_0_10_centos git-2.19.0]# make && make install
7、配置环境变量
[root@VM_0_10_centos git-2.19.0]# export PATH=$PATH:/usr/local/git/bin
8、查看git版本号
[root@VM_0_10_centos git-2.19.0]# git --version
git version 2.19.0
安装结束。