Linux環境的git安裝有多種方法:1,yum install git*,這樣的方法是有侷限性,聽說yum源中安裝的git版本是1.7.1,Github等須要的Git版本最低都不能低於1.7.2,個人虛擬機系統版本是CentOS6,yum源裏是沒有git可供下載的,因此咱們如今考慮方法2或者方法3;2, 雲端下載git版本,而後解壓編譯。3,網上下載git版本,而後導入Linux的指定目錄下,解壓編譯git
下面的方法都是方法2/3須要經歷的過程:github
1.安裝yum依賴包vim
須要擁有必定的權限,這裏我用的是root權限,bash
yum install zlib-devel
yum install openssl-devel
yum install perl
yum install cpio
yum install expat-devel
yum install gettext-devel
yum install autoconf dom
2.下載git源碼ssh
wget https://github.com/git/git/archive/v2.3.0.zipide
unzip v2.3.0.zipspa
cd git-2.3.0ip
3.編譯安裝gitssl
將其安裝在「/usr/local/git」目錄下。
make prefix=/usr/local/git all
make prefix=/usr/local/git install
這裏有能夠會報錯:
usr/bin/perl Makefile.PL PREFIX='/usr/local/git' INSTALL_BASE='' --localedir='/usr/local/git/share/locale'
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.
make[1]: *** [perl.mak] Error 2
make: *** [perl/perl.mak] Error 2
解決方法:
安裝依賴包:yum install perl-ExtUtils-MakeMaker package.
而後再從新編譯安裝git:
make prefix=/usr/local/git all
make prefix=/usr/local/git install
4.配置環境變量
進入環境變量配置文件:vim /etc/profile
pATH裏添加git的指定路徑:個人路徑是,/usr/local/git/bin
source /etc/profile:這個命令是讓修改的文件生效
完了以後查看git是否安裝成功:git --version
5.生成SSH密鑰過程
[root@localhost bin]# git config --global user.name "oscar.xie"
[root@localhost bin]# git config --global user.email "oscar.xie@amoby.com"
[root@localhost bin]# cd ~/.ssh
-bash: cd: /root/.ssh: No such file or directory
[root@localhost bin]# ssh-keygen -t rsa -C 「oscar.xie@amoby.com」
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 這裏輸入回車
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 這裏輸入回車
Enter same passphrase again: 這裏輸入回車 3個回車輸入表示密碼爲空!
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
74:e9:ef:c5:f3:73:df:93:51:42:92:4b:ad:c4:c5:f5 「oscar.xie@amoby.com」
The key's randomart image is:
+--[ RSA 2048]----+
| . =...|
| .* + .|
| . oo = E|
| . o o . .|
| S . ..|
| . . . |
| . + o|
| . . *o|
| . O|
+-----------------+
[root@localhost bin]# cd ~/.ssh
[root@localhost .ssh]# ll
total 8
-rw-------. 1 root root 1679 Nov 19 19:37 id_rsa
-rw-r--r--. 1 root root 407 Nov 19 19:37 id_rsa.pub