之所以写这篇文章的初衷是由于本人在 CentOS7 使用 yum 无法安装到最新版本的 git,通过查询 Git 官网得知,需下载源码进行源码编译安装。又考虑到大多数人员对于 Linux 一知半解,无法快速上手,故写下这篇文章,以供参考。
# 1. 下载
| |
| wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.38.1.tar.gz |
# 2. 安装依赖包
| yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc |
| yum install gcc perl-ExtUtils-MakeMaker |
| |
# 3. 删除原有 git 版本
# 4. 解压缩文件并移动至指定位置
| |
| tar -zxvf git-2.38.1.tar.gz |
| |
| mv git-2.38.1 /usr/local/soft/ |
# 5. 编译安装
| |
| cd /usr/local/soft/git-2.38.1/ |
| |
| ./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv |
| |
| make |
| make install |
# 6. 配置环境变量
| |
| echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile |
| |
| source /etc/profile |
# 7. 使用 git --version 命令查看最新版本
# 8. 全局配置
| git config --global user.name |
| git config --global user.email |