安装Git

作者: 鱼__鱼 | 来源:发表于2018-09-29 17:39 被阅读0次

    推荐学习Git教程-廖雪峰

    一. git --version 查看系统是否已经安装git

    [root@localhost ~]# git --version
    -bash: git: command not found
    

    二. yum install git CentOS7 yum安装git

    [root@localhost ~]# yum install git
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * webtatic: us-east.repo.webtatic.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package git.x86_64 0:1.8.3.1-14.el7_5 will be installed
    --> Processing Dependency: perl-Git = 1.8.3.1-14.el7_5 for package: git-1.8.3.1-14.el7_5.x86_64
    --> Processing Dependency: perl(Git) for package: git-1.8.3.1-14.el7_5.x86_64
    --> Running transaction check
    ---> Package perl-Git.noarch 0:1.8.3.1-14.el7_5 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =========================================================================================================================================================================================
     Package                                    Arch                                     Version                                             Repository                                 Size
    =========================================================================================================================================================================================
    Installing:
     git                                        x86_64                                   1.8.3.1-14.el7_5                                    updates                                   4.4 M
    Installing for dependencies:
     perl-Git                                   noarch                                   1.8.3.1-14.el7_5                                    updates                                    54 k
    
    Transaction Summary
    =========================================================================================================================================================================================
    Install  1 Package (+1 Dependent package)
    
    Total download size: 4.5 M
    Installed size: 22 M
    Is this ok [y/d/N]: y
    Downloading packages:
    (1/2): perl-Git-1.8.3.1-14.el7_5.noarch.rpm                                                                                                                       |  54 kB  00:00:00
    (2/2): git-1.8.3.1-14.el7_5.x86_64.rpm                                                                                                                            | 4.4 MB  00:00:00
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                                                     20 MB/s | 4.5 MB  00:00:00
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : perl-Git-1.8.3.1-14.el7_5.noarch                                                                                                                                      1/2
      Installing : git-1.8.3.1-14.el7_5.x86_64                                                                                                                                           2/2
      Verifying  : git-1.8.3.1-14.el7_5.x86_64                                                                                                                                           1/2
      Verifying  : perl-Git-1.8.3.1-14.el7_5.noarch                                                                                                                                      2/2
    
    Installed:
      git.x86_64 0:1.8.3.1-14.el7_5
    
    Dependency Installed:
      perl-Git.noarch 0:1.8.3.1-14.el7_5
    
    Complete!
    

    三. 重复步骤一,验证是否安装成功

    [root@localhost ~]# git --version
    git version 1.8.3.1
    

    四. yum -y upgrade git 升级(发现安装git版本过低,发现升级无效)

    [root@localhost ~]# yum -y upgrade git
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * webtatic: uk.repo.webtatic.com
    No packages marked for update
    

    五. yum remove git 卸载

    [root@localhost ~]# yum remove git
    Loaded plugins: fastestmirror
    Resolving Dependencies
    --> Running transaction check
    ---> Package git.x86_64 0:1.8.3.1-14.el7_5 will be erased
    --> Processing Dependency: git = 1.8.3.1-14.el7_5 for package: perl-Git-1.8.3.1-14.el7_5.noarch
    --> Running transaction check
    ---> Package perl-Git.noarch 0:1.8.3.1-14.el7_5 will be erased
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =========================================================================================================================================================================================
     Package                                    Arch                                     Version                                            Repository                                  Size
    =========================================================================================================================================================================================
    Removing:
     git                                        x86_64                                   1.8.3.1-14.el7_5                                   @updates                                    22 M
    Removing for dependencies:
     perl-Git                                   noarch                                   1.8.3.1-14.el7_5                                   @updates                                    57 k
    
    Transaction Summary
    =========================================================================================================================================================================================
    Remove  1 Package (+1 Dependent package)
    
    Installed size: 22 M
    Is this ok [y/N]: y
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Erasing    : perl-Git-1.8.3.1-14.el7_5.noarch                                                                                                                                      1/2
      Erasing    : git-1.8.3.1-14.el7_5.x86_64                                                                                                                                           2/2
      Verifying  : git-1.8.3.1-14.el7_5.x86_64                                                                                                                                           1/2
      Verifying  : perl-Git-1.8.3.1-14.el7_5.noarch                                                                                                                                      2/2
    
    Removed:
      git.x86_64 0:1.8.3.1-14.el7_5
    
    Dependency Removed:
      perl-Git.noarch 0:1.8.3.1-14.el7_5
    
    Complete!
    

    六. 现在又要重新安装git了

    在Git的官网上,对Red Hat Linux安装git建议有两种方法
    1、下载源代码、编译、构建、配置环境变量
    2、第三方仓库IUS

    本文采用IUS第三方仓库安装的方式。第一种方式自行google
    这里是ius官方的安装说明使用说明

    IUS安装2.x

    1. curl https://setup.ius.io | sh 安装使用说明里面自动化安装脚本
    [root@localhost ~]# curl https://setup.ius.io | sh
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  1914  100  1914    0     0    538      0  0:00:03  0:00:03 --:--:--   538
    detected CentOS 7
    EL 7 is supported
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * webtatic: sp.repo.webtatic.com
    Package epel-release-7-11.noarch already installed and latest version
    Nothing to do
    Loaded plugins: fastestmirror
    ius-release.rpm                                                                                                                                                   | 8.1 kB  00:00:00
    Examining /var/tmp/yum-root-bjXg18/ius-release.rpm: ius-release-1.0-15.ius.centos7.noarch
    Marking /var/tmp/yum-root-bjXg18/ius-release.rpm to be installed
    Resolving Dependencies
    --> Running transaction check
    ---> Package ius-release.noarch 0:1.0-15.ius.centos7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =========================================================================================================================================================================================
     Package                                    Arch                                  Version                                              Repository                                   Size
    =========================================================================================================================================================================================
    Installing:
     ius-release                                noarch                                1.0-15.ius.centos7                                   /ius-release                                8.5 k
    
    Transaction Summary
    =========================================================================================================================================================================================
    Install  1 Package
    
    Total size: 8.5 k
    Installed size: 8.5 k
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : ius-release-1.0-15.ius.centos7.noarch                                                                                                                                 1/1
      Verifying  : ius-release-1.0-15.ius.centos7.noarch                                                                                                                                 1/1
    
    Installed:
      ius-release.noarch 0:1.0-15.ius.centos7
    
    Complete!
    
    1. yum search git 查询git2u相关内容
    ...
    ...
    ...
    ================================================================================== N/S matched: git2u ===================================================================================
    git2u-debuginfo.x86_64 : Debug information for package git2u
    emacs-git2u.noarch : Git version control system support for Emacs
    emacs-git2u-el.noarch : Elisp source files for git version control system support for Emacs
    git2u.x86_64 : Fast Version Control System
    git2u-all.noarch : Meta-package to pull in all git tools
    git2u-core.x86_64 : Core package of git with minimal functionality
    git2u-core-doc.noarch : Documentation files for git-core
    git2u-cvs.noarch : Git tools for importing CVS repositories
    git2u-daemon.x86_64 : Git protocol daemon
    git2u-email.noarch : Git tools for sending email
    git2u-gitk.noarch : Git repository browser
    git2u-gitweb.noarch : Simple web interface to git repositories
    git2u-gui.noarch : Graphical interface to Git
    git2u-p4.noarch : Git tools for working with Perforce depots
    git2u-perl-Git.noarch : Perl interface to Git
    git2u-perl-Git-SVN.noarch : Perl interface to Git::SVN
    git2u-subtree.x86_64 : Git tools to merge and split repositories
    git2u-svn.x86_64 : Git tools for importing Subversion repositories
    
      Name and summary matches only, use "search all" for everything.
    ...
    ...
    ...
    
    1. yum remove -y git | yum -y install git2u 命令执行安装
    ...
    ...
    ...
      Memory :  24 M RSS (345 MB VSZ)
        Started: Thu Sep 27 18:13:53 2018 - 00:00 ago
        State  : Running, pid: 25364
    Loading mirror speeds from cached hostfile
     * ius: mirrors.tongji.edu.cn
     * webtatic: uk.repo.webtatic.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package git2u.x86_64 0:2.16.4-1.ius.centos7 will be installed
    --> Processing Dependency: git2u-core = 2.16.4-1.ius.centos7 for package: git2u-2.16.4-1.ius.centos7.x86_64
    --> Processing Dependency: git2u-core-doc = 2.16.4-1.ius.centos7 for package: git2u-2.16.4-1.ius.centos7.x86_64
    --> Processing Dependency: git2u-perl-Git = 2.16.4-1.ius.centos7 for package: git2u-2.16.4-1.ius.centos7.x86_64
    --> Processing Dependency: perl(Git) for package: git2u-2.16.4-1.ius.centos7.x86_64
    --> Processing Dependency: perl(Git::I18N) for package: git2u-2.16.4-1.ius.centos7.x86_64
    --> Processing Dependency: libsecret-1.so.0()(64bit) for package: git2u-2.16.4-1.ius.centos7.x86_64
    --> Running transaction check
    ---> Package git2u-core.x86_64 0:2.16.4-1.ius.centos7 will be installed
    ---> Package git2u-core-doc.noarch 0:2.16.4-1.ius.centos7 will be installed
    ---> Package git2u-perl-Git.noarch 0:2.16.4-1.ius.centos7 will be installed
    ---> Package libsecret.x86_64 0:0.18.5-2.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =========================================================================================================================================================================================
     Package                                        Arch                                   Version                                                Repository                            Size
    =========================================================================================================================================================================================
    Installing:
     git2u                                          x86_64                                 2.16.4-1.ius.centos7                                   ius                                  1.1 M
    Installing for dependencies:
     git2u-core                                     x86_64                                 2.16.4-1.ius.centos7                                   ius                                  5.5 M
     git2u-core-doc                                 noarch                                 2.16.4-1.ius.centos7                                   ius                                  2.4 M
     git2u-perl-Git                                 noarch                                 2.16.4-1.ius.centos7                                   ius                                   67 k
     libsecret                                      x86_64                                 0.18.5-2.el7                                           base                                 151 k
    
    Transaction Summary
    =========================================================================================================================================================================================
    Install  1 Package (+4 Dependent packages)
    
    Total download size: 9.2 M
    Installed size: 42 M
    Downloading packages:
    (1/5): libsecret-0.18.5-2.el7.x86_64.rpm                                                                                                                          | 151 kB  00:00:00
    (2/5): git2u-2.16.4-1.ius.centos7.x86_64.rpm                                                                                                                      | 1.1 MB  00:00:00
    (3/5): git2u-core-2.16.4-1.ius.centos7.x86_64.rpm                                                                                                                 | 5.5 MB  00:00:00
    (4/5): git2u-core-doc-2.16.4-1.ius.centos7.noarch.rpm                                                                                                             | 2.4 MB  00:00:03
    (5/5): git2u-perl-Git-2.16.4-1.ius.centos7.noarch.rpm                                                                                                             |  67 kB  00:00:09
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                                                    960 kB/s | 9.2 MB  00:00:09
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : git2u-core-2.16.4-1.ius.centos7.x86_64                                                                                                                                1/5
      Installing : git2u-core-doc-2.16.4-1.ius.centos7.noarch                                                                                                                            2/5
      Installing : libsecret-0.18.5-2.el7.x86_64                                                                                                                                         3/5
      Installing : git2u-perl-Git-2.16.4-1.ius.centos7.noarch                                                                                                                            4/5
      Installing : git2u-2.16.4-1.ius.centos7.x86_64                                                                                                                                     5/5
      Verifying  : git2u-2.16.4-1.ius.centos7.x86_64                                                                                                                                     1/5
      Verifying  : git2u-core-doc-2.16.4-1.ius.centos7.noarch                                                                                                                            2/5
      Verifying  : git2u-core-2.16.4-1.ius.centos7.x86_64                                                                                                                                3/5
      Verifying  : git2u-perl-Git-2.16.4-1.ius.centos7.noarch                                                                                                                            4/5
      Verifying  : libsecret-0.18.5-2.el7.x86_64                                                                                                                                         5/5
    
    Installed:
      git2u.x86_64 0:2.16.4-1.ius.centos7
    
    Dependency Installed:
      git2u-core.x86_64 0:2.16.4-1.ius.centos7      git2u-core-doc.noarch 0:2.16.4-1.ius.centos7      git2u-perl-Git.noarch 0:2.16.4-1.ius.centos7      libsecret.x86_64 0:0.18.5-2.el7
    
    Complete!
    
    1. git --version 查看版本,验证安装成功
    [root@localhost ~]# git --version
    git version 2.16.4
    

    相关文章

      网友评论

          本文标题:安装Git

          本文链接:https://www.haomeiwen.com/subject/rdsboftx.html