CentOS 7.4 系统安装 git

CentOS 7.4 系统安装 git

一、使用 yum 安装

1、查看系统是否已经安装 git

[root@localhost ~]# git --version

2、yum 安装 git

[root@localhost ~]# yum install git

3、安装成功

[root@localhost ~]# git version

git version 1.7.1

[root@localhost ~]# git --version

git version 1.7.1

4、卸载 git

[root@localhost ~]# yum remove git

二、源代码安装

在 Linux 下安装 git

git 是一个开源的分布式版本控制系统,可以有效、高速的处理从很小到非常大的项目版本管理。而国外的 GitHub 和国内的 Coding 都是项目的托管平台,但是在使用 git 工具的时候,第一步要学会如何安装 git,本教程就手把手教大家如何手动编译安装 git。

1、介绍

使用 Coding 管理项目,上面要求使用的 git 版本为 1.8.0 以上,而很多 yum 源上自动安装的 git 版本为 1.7,所以需要掌握手动编译安装 git 方法。

2、安装 git 依赖包

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

3、删除已有的 git

yum remove git

4、下载 git 源码

4.1、切换到你的包文件存放目录下

cd /usr/src

4.2、下载 git 安装包

wget https://www.kernel.org/pub/software/scm/git/git-2.8.3.tar.gz --no-check-certificate

4.3、解压 git 安装包

tar -zxvf git-2.8.3.tar.gz

cd git-2.8.3

4.4、配置 git 安装路径

./configure prefix=/usr/local/git/

4.5、编译并且安装

make && make install

5、将 git 指令添加到 bash 中

vi /etc/profile

在最后一行加入

export PATH=$PATH:/usr/local/git/bin

让该配置文件立即生效

source /etc/profile

6、查看 git 版本号

git --version

[root@localhost ~]# git version

git version 2.8.3

git 已经安装完毕

参考资料

猜你喜欢

转载自www.cnblogs.com/hglibin/p/10699238.html