1. 程式人生 > >linux下安裝git

linux下安裝git

git

1:git安裝

	1.1:安裝git環境準備
	1.2:創建用戶及配置家目錄
	1.3:編譯安裝
	1.4:環境配置
	1.5:配置幫助文件
	1.6:查看版本
	1.7:認證



git下載地址:

https://mirrors.edge.kernel.org/pub/software/scm/git/


1:git安裝

1.1:安裝git環境準備

yum -y install gcc openssl openssl-devel curl curl-devel unzip perl perl-devel expat expat-devel zlib zlib-devel asciidoc xmlto gettext-devel openssh-clients

1.2:創建用戶及配置家目錄

[root@testss git]# useradd -r -s /bin/bash -d /home/git git
[root@testss git]# mkdir /home/git
[root@testss git]# chown git.git /home/git/ -R

1.3:編譯安裝

[root@testss git-2.9.5]# tar xf git-2.9.5.tar.xz 
[root@testss git-2.9.5]# cd git-2.9.5
[root@testss git-2.9.5]# ./configure --prefix=/usr/local/git --with-openssl --with-libpcre 
[root@testss git-2.9.5]# make -j 2 && make -j 2 install


1.4:環境配置

[root@testss git-2.9.5]# echo "export PATH=/usr/local/git/bin/:$PATH" > /etc/profile.d/git.sh
[root@testss git-2.9.5]# source !$


1.5:配置幫助文件

[root@testss git-2.9.5]# /usr/local/git/share
[root@testss share]# ln -sv man/ /usr/share/

1.6:查看版本

[root@testss share]# git --version
  git version 2.9.5


1.7:認證

[root@testss share]# ssh-keygen 
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: 
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:
34:25:50:bd:96:f9:63:c7:f8:a3:c7:76:2c:c5:c5:79 root@testss
The key's randomart image is:
+--[ RSA 2048]----+
|      .oo..      |
|         o.      |
|        o  +   ..|
|       . .=    .E|
|        S. . o .o|
|            = o o|
|           . = o |
|              B o|
|            .+ + |
+-----------------+

// 配置用戶權限
[root@testss share]# cd /home/git
[root@testss git]# mkdir .ssh
[root@testss git]# chmod 700 .ssh/
[root@testss git]# chmod 600 /home/git/.ssh/authorized_keys 
[root@testss git]# chown git.git .ssh/ -R

//建立雙機互信
[root@testss git]# cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys

// git免密登陸
[root@testss git]# cat ~/.ssh/id_rsa.pub > /home/git/.ssh/authorized_keys





linux下安裝git