安裝Git

推薦學(xué)習(xí)Git教程-廖雪峰

一. git --version 查看系統(tǒng)是否已經(jīng)安裝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!

三. 重復(fù)步驟一和蚪,驗(yàn)證是否安裝成功

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

四. yum -y upgrade git 升級(jí)(發(fā)現(xiàn)安裝git版本過低,發(fā)現(xiàn)升級(jí)無效)

[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!

六. 現(xiàn)在又要重新安裝git了

在Git的官網(wǎng)上僵刮,對(duì)Red Hat Linux安裝git建議有兩種方法
1滥崩、下載源代碼岖圈、編譯、構(gòu)建钙皮、配置環(huán)境變量
2蜂科、第三方倉(cāng)庫IUS

本文采用IUS第三方倉(cāng)庫安裝的方式。第一種方式自行g(shù)oogle
這里是ius官方的安裝說明使用說明

IUS安裝2.x

  1. curl https://setup.ius.io | sh 安裝使用說明里面自動(dòng)化安裝腳本
[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相關(guān)內(nèi)容
...
...
...
================================================================================== 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 命令執(zhí)行安裝
...
...
...
  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.#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 查看版本短条,驗(yàn)證安裝成功
[root@localhost ~]# git --version
git version 2.16.4
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末导匣,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子茸时,更是在濱河造成了極大的恐慌贡定,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,084評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件屹蚊,死亡現(xiàn)場(chǎng)離奇詭異厕氨,居然都是意外死亡进每,警方通過查閱死者的電腦和手機(jī)汹粤,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,623評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來田晚,“玉大人嘱兼,你說我怎么就攤上這事∠屯剑” “怎么了芹壕?”我有些...
    開封第一講書人閱讀 163,450評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)接奈。 經(jīng)常有香客問我踢涌,道長(zhǎng),這世上最難降的妖魔是什么序宦? 我笑而不...
    開封第一講書人閱讀 58,322評(píng)論 1 293
  • 正文 為了忘掉前任睁壁,我火速辦了婚禮,結(jié)果婚禮上互捌,老公的妹妹穿的比我還像新娘潘明。我一直安慰自己,他們只是感情好秕噪,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,370評(píng)論 6 390
  • 文/花漫 我一把揭開白布钳降。 她就那樣靜靜地躺著,像睡著了一般腌巾。 火紅的嫁衣襯著肌膚如雪遂填。 梳的紋絲不亂的頭發(fā)上铲觉,一...
    開封第一講書人閱讀 51,274評(píng)論 1 300
  • 那天,我揣著相機(jī)與錄音吓坚,去河邊找鬼备燃。 笑死,一個(gè)胖子當(dāng)著我的面吹牛凌唬,可吹牛的內(nèi)容都是我干的并齐。 我是一名探鬼主播,決...
    沈念sama閱讀 40,126評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼客税,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼况褪!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起更耻,我...
    開封第一講書人閱讀 38,980評(píng)論 0 275
  • 序言:老撾萬榮一對(duì)情侶失蹤测垛,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后秧均,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體食侮,經(jīng)...
    沈念sama閱讀 45,414評(píng)論 1 313
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,599評(píng)論 3 334
  • 正文 我和宋清朗相戀三年目胡,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了锯七。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,773評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡誉己,死狀恐怖眉尸,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情巨双,我是刑警寧澤噪猾,帶...
    沈念sama閱讀 35,470評(píng)論 5 344
  • 正文 年R本政府宣布,位于F島的核電站筑累,受9級(jí)特大地震影響袱蜡,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜慢宗,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,080評(píng)論 3 327
  • 文/蒙蒙 一坪蚁、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧婆廊,春花似錦迅细、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,713評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至宾舅,卻和暖如春统阿,著一層夾襖步出監(jiān)牢的瞬間彩倚,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,852評(píng)論 1 269
  • 我被黑心中介騙來泰國(guó)打工扶平, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留帆离,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,865評(píng)論 2 370
  • 正文 我出身青樓结澄,卻偏偏與公主長(zhǎng)得像哥谷,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子麻献,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,689評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容