安装Git

推荐学习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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,684评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,143评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,214评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,788评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,796评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,665评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,027评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,679评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 41,346评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,664评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,766评论 1 331
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,412评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,015评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,974评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,203评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,073评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,501评论 2 343

推荐阅读更多精彩内容