CentOS7.6升级Git版本

安装centos7最小化系统,再安装VIM插件coc.nvim出现
Error: javascript bundle not found, please compile code ~ | of coc.nvim by esbuild.
或者出现:
please compile coc.nvim by: npm run build

不管怎样就是安装不上,查资料也不管,最后重新装系统都不行,有的说是升级git,升级后再安装确实管用,但也不一定是这个问题。记录一下git升级

CentOS7上的Git版本太陈旧,在使用过程中会遇到问题,因此需要升级git版本。

git --version

git version 1.8.3.1
  系统版本:(CentOS 7.6)

安装依赖
  源代码安装和编译git,需安装一些依赖。

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

卸载旧版本
yum remove git

编译安装Git
  Git软件包可在此获取:https://mirrors.edge.kernel.org/pub/software/scm/git/

  我们选择最新版的:

git-2.23.0.tar.xz 16-Aug-2019 20:17 5M

安装步骤
复制代码

cd /usr/local/
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.23.0.tar.xz
tar -xvf git-2.23.0.tar.xz
mv git-2.23.0 git
cd git
./configure  --prefix=/usr/local
make && make install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
source /etc/profile

验证版本
[root@localhost ~]# git --version
git version 2.23.0

非root用户使用
如果是非root用户使用git,则需要配置下该用户下的环境变量。

$ echo "export PATH=$PATH:/usr/local/git/bin" >> ~/.bashrc
$ source ~/.bashrc