Linux安装git(操作系统CentOS)

git 官网下载安装包

git官网地址
在这里插入图片描述

安装git

我安装git的操作系统CentOS 7.7 64位

我通过Xftp 7 把下载好的git安装包上传到服务器
在这里插入图片描述
在这里插入图片描述

我把git安装包上传到服务的/usr/local/目录下

[root@localhost /]# cd /usr/local/

解压安装包

[root@localhost local]# tar -zxvf git-2.41.0.tar.gz

安装编译环境

[root@localhost local]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

安装git编译环境的时候,yum自动帮你安装了git,你要卸载这个旧版本的git

[root@localhost local]# git --version
git version 1.8.3.1

卸载编译环境帮你自动安装的git

[root@localhost local]# yum remove git

先去到你的git目录下

[root@localhost local]# cd git-2.41.0

开始编译安装

[root@localhost git-2.41.0]# make prefix=/opt/git all
[root@localhost git-2.41.0]# make prefix=/opt/git install

配置环境变量

[root@localhost git-2.41.0]# vim /etc/profile

把下面的变量添加到文件的最后

export GIT_HOME=/opt/git
export PATH=$GIT_HOME/bin:$PATH

保持内容后刷新源

[root@localhost git-2.41.0]# source /etc/profile

查看git版本

[root@localhost git-2.41.0]# git --version
git version 2.41.0

成功

猜你喜欢

转载自blog.csdn.net/qq407995680/article/details/132356876