Linux下安装Git
第一步:准备安装Git所需的依赖
执行下面的命令
[developer@tencent-centos1 ~]$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
第二步:下载获取Git源码包
[developer@tencent-centos1 ~]$ wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.13.6.tar.gz
如果想要下载别的版本的,可以去这个地址下载:
https://mirrors.edge.kernel.org/pub/software/scm/git/
选择对应版本的tar.gz的包,替换到上面命令wget后的地址即可。
第三步:解压、配置安装目录并进行安装
依次执行以下命令:
1、解压
2、进入解压后的目录
3、配置安装目录为/opt/git下
4、执行安装
[developer@tencent-centos1 ~]$ tar -zxvf git-2.13.6.tar.gz [developer@tencent-centos1 ~]$ cd git-2.13.6 [developer@tencent-centos1 ~]$ ./configure prefix=/opt/git [developer@tencent-centos1 ~]$ make && make install
第四步:配置环境变量
执行下面的命令,在文件末尾加上 export PATH = $PATH:/opt/git/bin
[developer@tencent-centos1 ~]$ vim /etc/profile
让配置立即生效:
[developer@tencent-centos1 ~]$ source /etc/profile
输入下面的命令,如果出现了版本号则表示安装成功~
[developer@tencent-centos1 ~]$ git --version
git version 2.13.6