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

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

问题描述

我用的是通常的:

  yum install git 

但是没有在我的CentOS 6.4上安装最新版本的git。那么,如何更新到CentOS 6.4的最新版本?



注意:



解决方案

查看博客在这里我在其中一个评论中找到了解决方案。确保您已将 rpmforge 存储库添加到您的CentOS yum,然后只需运行以下命令:

  yum --disablerepo = base,updates --enablerepo = rpm forge-extras install git 

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

  yum --disablerepo = base,updates --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:



同时感谢@Axlrod提供下面的提示和@Hiphip反馈:



更改 rpmforge.repo 文件以启用 rpmforge-extras
yum update git



注意更新3:




git的特定版本说2.x
我发现这个漂亮和容易遵循的指南,如何下载GIT源,并自己编译(并安装它)。如果接受的答案没有给您所需的版本,请尝试以下说明:


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



(从上面粘贴/重新格式化,以备日后移除)



:安装所需的软件包



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

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

2:卸载旧的Git RPM



现在,通过RPM文件或Yum软件包管理器删除以前安装的任何Git。如果您的旧版本也通过源代码编译,则跳过此步骤。

 #yum remove git 



步骤3:下载并编译Git源



从内核git下载git源代码或者只需使用下面的命令下载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

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

 #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
#或
#echo'export PATH = $ PATH:/ usr / local / git / bin'> /etc/profile.d/git.sh

#source / etc / bashrc


$ b b


HINT:
将编译的git bin目录添加到bashrc的更新方法。因为 echoexport PATH = $ PATH:/ usr / local / git / bin>> / etc / bashrc 使用而不是',它会扩展$ PATH的当前会话的值,而不是保持它作为一个变量,可能会对整个系统产生不利影响。至少应该使用''而不是,而且应该是 /etc/profile.d/


中的一个单独的脚本。 / blockquote>

步骤4。检查Git版本



完成上述步骤后,成功地在你的系统中安装Git。让使用下面的命令检查git版本

 #git --version 

git version 2.0.4

我还想补充一点,GIT网站上的入门指南自行下载并编译:



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


I used the usual:

yum install git

But it did not install the latest version of git on my CentOS 6.4. So, how can I update to the latest version for CentOS 6.4?

Note:

The solution can be applicable to other newly released versions of CentOS such as CentOS 7.x.

解决方案

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: 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/

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 6.x / 7.x上安装最新版本的git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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