Linux下git使用源码与yum的安装方法

Linux下git使用源码与yum的安装方法

Linux下安装git使用源代码或yum的两种方法,以安装最新的git版本。

方法一:git的源码安装方法

首先要查看git最新版本,可访问以下网址: https://git-scm.com/downloads https://github.com/git/git/releases

1、查看当前Linux下git版本

# git --version

如不是最新版本,可使用以下命令移除,重新下载安装最新版本。

# yum remove git

2、git安装前准备工作

# yum install libcurl-devel libtool zlib zlib-devel autoconf automake perl-ExtUtils-MakeMaker package tcl build-essential tk gettext libiconv

注:为了防止git安装完后出现异常报错问题,需先安装以上依赖包。

3、安装git

# wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.23.0.tar.gz    //官网下载git源码包
# tar -zxvf git-2.23.0.tar.gz   //解压已下载git源码包
# cd git-2.23.0
# make configure
# ./configure --prefix=/usr/local/git --with-iconv --with-curl --with-expat=/usr/local/lib
# make && make install
# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
# source /etc/bashrc
# git --version

方法二:git的yum安装方法

1、CentOS 6 安装方法

# yum install -y epel-release
# rpm -ivh https://centos6.iuscommunity.org/ius-release.rpm
# yum list git2u
# yum install -y git2u
# git --version

2、CentOS 7 安装方法

# yum install -y epel-release
# rpm -ivh https://centos7.iuscommunity.org/ius-release.rpm
# yum list git2u
# yum install -y git2u
# git --version

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×