Git 安装

CentOS

yum安装

yum install git

通过yum方式安装,版本比较旧,CentOS6.5上安装好是1.7.1版。如果想安装最新版或其他版本,需要使用源码编译安装的方式。

源码包安装

安装依赖包

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

卸载旧的git版本(如果之前有安装rpm包)

yum remove git

下载&解压

cd /usr/src
wget https://www.kernel.org/pub/software/scm/git/git-2.5.0.tar.gz
tar -zxvf git-2.5.0.tar.gz

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

步骤4. 编译安装

cd git-2.5.0
make prefix=/usr/local/git all
make prefix=/usr/local/git install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc

检查git版本

git --version
# git version 2.5.0

Mac

Mac我建议用brew安装,因为升级方便可以下载一个cakebrew,搜索git安装即可

results matching ""

    No results matching ""