centos7 git安裝

    因爲centos中的源倉庫中git不是最新版本,須要進行源碼安裝。git

一、查看yum倉庫git信息

[root@iZm5e3d4r5i5ml889vh6esZ zh]# yum info git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
Name        : git
Arch        : x86_64
Version     : 1.8.3.1
Release     : 13.el7
Size        : 22 M
Repo        : installed
From repo   : base
Summary     : Fast Version Control System
URL         : http://git-scm.com/
License     : GPLv2
Description : Git is a fast, scalable, distributed revision control system with an
            : unusually rich command set that provides both high-level operations
            : and full access to internals.
            : 
            : The git rpm installs the core tools with minimal dependencies.  To
            : install all git packages, including tools for integrating with other
            : SCMs, install the git-all meta-package.

二、依賴倉庫安裝

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

三、卸載已安裝的git

[root@iZm5e3d4r5i5ml889vh6esZ zh]# yum remove git

四、下載git最新源碼

    下載地址:https://github.com/git/git/releasesgithub

wget https://github.com/git/git/archive/v2.17.1.tar.gz

五、安裝

    解壓、安裝vim

[root@iZm5e3d4r5i5ml889vh6esZ git]# tar zxvf v2.17.1.tar.gz 
[root@iZm5e3d4r5i5ml889vh6esZ git]# cd git-2.17.1/
[root@iZm5e3d4r5i5ml889vh6esZ git]# make prefix=/usr/local/git all
[root@iZm5e3d4r5i5ml889vh6esZ git]# make prefix=/usr/local/git install

六、添加到環境變量

[root@iZm5e3d4r5i5ml889vh6esZ git]# vim /etc/profile
export GIT_HOME=/usr/local/git

export PATH=$GIT_HOME/bin:$PATH
[root@iZm5e3d4r5i5ml889vh6esZ git]# source /etc/profile

七、查看當前版本號

[root@iZm5e3d4r5i5ml889vh6esZ git]# git --version
git version 2.17.1
相關文章
相關標籤/搜索