如何为 CentOS 安装 git?

如何为 CentOS 安装 git?

我尝试了一些建议这个答案但它们都不起作用。

[root@308321 sugar-dev]# yum install git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.ubiquityservers.com
 * epel: www.gtlib.gatech.edu
 * extras: mirrors.usinternet.com
 * updates: mirrors.serveraxis.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.2.1-1.el5 will be installed
--> Processing Dependency: perl-Git = 1.8.2.1-1.el5 for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: perl(Error) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libssl.so.6()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libexpat.so.0()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libcurl.so.3()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libcrypto.so.6()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Running transaction check
---> Package compat-expat1.x86_64 0:1.95.8-8.el6 will be installed
---> Package git.x86_64 0:1.8.2.1-1.el5 will be installed
--> Processing Dependency: libcurl.so.3()(64bit) for package: git-1.8.2.1-1.el5.x86_64
---> Package openssl098e.x86_64 0:0.9.8e-17.el6.centos.2 will be installed
---> Package perl-Error.noarch 1:0.17015-4.el6 will be installed
---> Package perl-Git.x86_64 0:1.8.2.1-1.el5 will be installed
--> Processing Dependency: perl(:MODULE_COMPAT_5.8.8) for package: perl-Git-1.8.2.1-1.el5.x86_64
---> Package perl-TermReadKey.x86_64 0:2.30-13.el6 will be installed
--> Finished Dependency Resolution
Error: Package: perl-Git-1.8.2.1-1.el5.x86_64 (epel)
           Requires: perl(:MODULE_COMPAT_5.8.8)
Error: Package: git-1.8.2.1-1.el5.x86_64 (epel)
           Requires: libcurl.so.3()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
[root@308321 sugar-dev]# yum -y install git --disablerepo=updates
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.ubiquityservers.com
 * epel: www.gtlib.gatech.edu
 * extras: mirrors.usinternet.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.2.1-1.el5 will be installed
--> Processing Dependency: perl-Git = 1.8.2.1-1.el5 for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: perl(Error) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libssl.so.6()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libexpat.so.0()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libcurl.so.3()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libcrypto.so.6()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Running transaction check
---> Package compat-expat1.x86_64 0:1.95.8-8.el6 will be installed
---> Package git.x86_64 0:1.8.2.1-1.el5 will be installed
--> Processing Dependency: libcurl.so.3()(64bit) for package: git-1.8.2.1-1.el5.x86_64
---> Package openssl098e.x86_64 0:0.9.8e-17.el6.centos.2 will be installed
---> Package perl-Error.noarch 1:0.17015-4.el6 will be installed
---> Package perl-Git.x86_64 0:1.8.2.1-1.el5 will be installed
--> Processing Dependency: perl(:MODULE_COMPAT_5.8.8) for package: perl-Git-1.8.2.1-1.el5.x86_64
---> Package perl-TermReadKey.x86_64 0:2.30-13.el6 will be installed
--> Finished Dependency Resolution
Error: Package: perl-Git-1.8.2.1-1.el5.x86_64 (epel)
           Requires: perl(:MODULE_COMPAT_5.8.8)
Error: Package: git-1.8.2.1-1.el5.x86_64 (epel)
           Requires: libcurl.so.3()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
[root@308321 sugar-dev]# yum install git --disableexcludes=main --skip-broken
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.ubiquityservers.com
 * epel: www.gtlib.gatech.edu
 * extras: mirrors.usinternet.com
 * updates: mirrors.serveraxis.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.2.1-1.el5 will be installed
--> Processing Dependency: perl-Git = 1.8.2.1-1.el5 for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: perl(Error) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libssl.so.6()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libexpat.so.0()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libcurl.so.3()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Processing Dependency: libcrypto.so.6()(64bit) for package: git-1.8.2.1-1.el5.x86_64
--> Running transaction check
---> Package compat-expat1.x86_64 0:1.95.8-8.el6 will be installed
---> Package git.x86_64 0:1.8.2.1-1.el5 will be installed
--> Processing Dependency: libcurl.so.3()(64bit) for package: git-1.8.2.1-1.el5.x86_64
---> Package openssl098e.x86_64 0:0.9.8e-17.el6.centos.2 will be installed
---> Package perl-Error.noarch 1:0.17015-4.el6 will be installed
---> Package perl-Git.x86_64 0:1.8.2.1-1.el5 will be installed
--> Processing Dependency: perl(:MODULE_COMPAT_5.8.8) for package: perl-Git-1.8.2.1-1.el5.x86_64
---> Package perl-TermReadKey.x86_64 0:2.30-13.el6 will be installed
--> Finished Dependency Resolution

Packages skipped because of dependency problems:
    compat-expat1-1.95.8-8.el6.x86_64 from base
    git-1.8.2.1-1.el5.x86_64 from epel
    openssl098e-0.9.8e-17.el6.centos.2.x86_64 from base
    1:perl-Error-0.17015-4.el6.noarch from base
    perl-Git-1.8.2.1-1.el5.x86_64 from epel
    perl-TermReadKey-2.30-13.el6.x86_64 from base
[root@308321 sugar-dev]# git
-bash: git: command not found
[root@308321 sugar-dev]#


[root@308321 sugar-dev]# uname -a
Linux 308321.oliveyou.net 2.6.32-220.2.1.el6.x86_64 #1 SMP Fri Dec 23 02:21:33 CST 2011 x86_64 x86_64 x86_64 GNU/Linux

答案1

你的问题不是git可用版本太少,而是太多;git位于 base/updates 存储库集中,但较新的版本也在 epel 中,并且它们互相踩对方的脚。您似乎还连接了旧版本的 epel 存储库(它正在获取.el5软件包),并且确实不会有帮助。

尝试

yum install git --disablerepo=epel

这应该会让你得到 1.7.1。如果有效,您可能还想修复您的 epel 存储库(位于/etc/yum.repos.d/epel.repo)并研究存储库优先级,这有助于防止较新版本的工具(通常来自附加存储库)踩在旧版本(来自核心存储库)上,除非您特别要求他们这样做。

答案2

您还应该查看有关存储库的 CentOS wiki 文章

http://wiki.centos.org/AdditionalResources/Repositories

您将在其中找到一些有关内容复制的信息。

您还可以尝试使用 Yum 插件:优先事项或者保护基地

这些应该有助于管理第三方包源。

相关内容