如何在CentOS 7.x / 6.x上安装最新版本的git [英] How to install latest version of git on CentOS 7.x/6.x

查看:158
本文介绍了如何在CentOS 7.x / 6.x上安装最新版本的git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我常用:

  yum install git 

它并未在我的CentOS 6上安装最新版本的git。如何更新为CentOS 6的最新版本的git?该解决方案可适用于较新版本的CentOS,例如CentOS 7。

http://akyl.net/how-install-latest-version-git-centos-6x =noreferrer>这里我在其中一条评论中找到了解决方案。确保你已将 rpmforge 存储库添加到CentOS yum中,并运行流程命令:

  yum --disablerepo = base,updates --enablerepo = rpmforge-extras install git 

如果您已经安装了git,请使用:

  yum --disablerepo = base,更新--enablerepo = rpmforge-extras更新git 

相关问题:


  1. 在将CentOS 6.4上的git升级到最新版本时遇到问题



注意更新:



感谢Anthony Hatzopoulos,对于 git v1.8x ,您需要使用git18:

  yum --disablerepo = base,updates --enablerepo = rpmforge-extras install git18 



注意更新2:



另外感谢s到@Axlrod以获得反馈:@ b
$ b

rpmforge.repo 文件更改为有 rpmforge-extras 启用,
yum update git 。否则它会抱怨依赖性问题。



注意更新3:




特定版本的git说2.x
我发现这个很好且易于遵循的指南,介绍如何下载GIT源代码并自行编译(并安装它)。如果接受的答案没有给出您想要的版本,请尝试以下说明:

http://tecadmin.net/install-git-2-0-on-centos-rhel-fedora /



(如果以后被删除,则从上面的源代码粘贴/重新格式化)

第1步:安装必需的软件包



首先,我们需要确保我们已经在您的系统上安装了所需的软件包。使用以下命令在编译Git源代码之前安装必需的包。

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

步骤2:卸载旧的Git RPM



现在,通过RPM文件或Yum包管理器删除任何先前安装的Git。如果您的旧版本也是通过源代码编译的,那么跳过这一步。

 #yum remove git 
下载并编译Git源代码





 #cd / usr / git从内核git下载git源代码或简单地使用以下命令下载Git 2.0.4。 src 
#wget https://www.kernel.org/pub/software/scm/git/git-2.0.4.tar.gz
#tar xzf git-2.0.4.tar.gz

下载并解压Git源代码后,使用以下命令编译源代码。

 #cd git-2.0.4 
#make prefix = / usr / local / git全部
#make prefix = / usr / local / git install

#echo'export PATH = $ PATH:/ usr / local / git / bin'>> / etc / bashrc
#或
#echo'export PATH = $ PATH:/ usr / local / git / bin'> /etc/profile.d/git.sh

#source / etc / bashrc




提示1:
将编译的git bin目录添加到bashrc的更新方法。由于 echoexport PATH = $ PATH:/ usr / local / git / bin>> / etc / bashrc 使用而不是',它会扩展当前会话的$ PATH值,而不是将其保留为变量,并可能对整个系统产生不利影响。至少应该使用'而不是,并且应该是 /etc/profile.d/ 中的单独脚本。



提示2(@DJB):
/ usr / local / git / bin $ PATH ,因为旧版本的git已经在$ PATH中: export PATH = / usr / local / git / bin:$ PATH


第四步检查Git版本



完成上述步骤,你已经成功在你的系统中安装Git。让我们使用以下命令来检查git版本

 #git --version 

git version 2.0.4

我还想补充一点,GIT网站上的Getting Started指南还包括如何自行下载并编译它:

http://git-scm.com/book/en/v2/Getting-Started-Installing-Git


I used the usual:

yum install git

It did not install the latest version of git on my CentOS 6. How can I update to the latest version of git for CentOS 6? The solution can be applicable to newer versions of CentOS such as CentOS 7.

解决方案

Having a look at the blog here I found the solution in one of the comments. Make sure you got the rpmforge repository added to your CentOS yum and just run the flowing command:

yum --disablerepo=base,updates --enablerepo=rpmforge-extras install git

If you already have git installed then use:

yum --disablerepo=base,updates --enablerepo=rpmforge-extras update git

Related question(s):

  1. Facing issues while upgrading git to latest version on CentOS 6.4

Note update:

Thanks to Anthony Hatzopoulos, for git v1.8x you'll need to use git18 as in:

yum --disablerepo=base,updates --enablerepo=rpmforge-extras install git18 

Note update 2:

Also thanks to @Axlrod for the below hint and @Hiphip for the feedback:

Change the rpmforge.repo file to have rpmforge-extras to enabled, yum update git. Otherwise it complained about dependency problems.

Note update 3:

Installing a specific version of git say 2.x I found this nice and easy-to-follow guide on how to download the GIT source and compile it yourself (and install it). If the accepted answer does not give you the version you want, try the following instructions:

http://tecadmin.net/install-git-2-0-on-centos-rhel-fedora/

(And pasted/reformatted from above source in case it is removed later)

Step 1: Install Required Packages

Firstly we need to make sure that we have installed required packages on your system. Use following command to install required packages before compiling Git source.

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

Step 2: Uninstall old Git RPM

Now remove any prior installation of Git through RPM file or Yum package manager. If your older version is also compiled through source, then skip this step.

# yum remove git

Step 3: Download and Compile Git Source

Download git source code from kernel git or simply use following command to download Git 2.0.4.

# cd /usr/src
# wget https://www.kernel.org/pub/software/scm/git/git-2.0.4.tar.gz
# tar xzf git-2.0.4.tar.gz

After downloading and extracting Git source code, Use following command to compile source code.

# cd git-2.0.4
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
#
# echo 'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc
#  or
# echo 'export PATH=$PATH:/usr/local/git/bin' > /etc/profile.d/git.sh
#
# source /etc/bashrc

HINT 1: Updated method of adding compiled git bin directory to bashrc. Because echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc used "" instead of '', it would expand the current session's value for $PATH instead of keeping it as a variable, and could adversely affect the entire system. At the minimum, it should use '' instead of "" and should really be a separate script in /etc/profile.d/

HINT 2 (@DJB): /usr/local/git/bin before $PATH, since the older version of git was already on $PATH: export PATH=/usr/local/git/bin:$PATH

Step 4. Check Git Version

One completion of above steps, you have successfully install Git in your system. Let use following command to check git version

# git --version

git version 2.0.4

I also wanted to add that the "Getting Started" guide at the GIT website also includes instructions on how to download and compile it yourself:

http://git-scm.com/book/en/v2/Getting-Started-Installing-Git

这篇关于如何在CentOS 7.x / 6.x上安装最新版本的git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆