cd /usr/local
mkdir git
源码安装
cd git
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
下载Git并解压
wget https://github.com/git/git/archive/v2.3.0.zip
unzip v2.3.0.zip
cd git-2.3.0
make prefix=/usr/local/git all
sudo make prefix=/usr/local/git install
whereis git
配置环境
如果你是centsos 7自带git1.8要自己先yum remove git 删除git1.8,,此外去看下/etc/profile.d/git.sh 删干净再来执行下面与配置/etc/profile一个效果
[root@bogon git-2.3.0]# echo "export PATH=$PATH:/usr/local/git/bin" > /etc/profile.d/git.sh
[root@bogon git-2.3.0]# source /etc/profile.d/git.sh
[root@bogon git-2.3.0]# git --version
git version 2.3.0
[root@bogon git-2.3.0]#
[root@bogon local]# cd git
[root@bogon git]# mkdir -p git-repo
[root@bogon git]# ll
total 6196
[root@bogon git]# git config --global user.name "chen1932390299"
[root@bogon git]# git config --global user.email [email protected]
[root@bogon git]# git config --list
user.name=chen1932390299
[email protected]
[root@bogon git]# cd git-repo/
[root@bogon git-repo]# echo “README” > readme.txt
[root@bogon git-repo]# ll
total 4
-rw-r--r--. 1 root root 11 Apr 20 15:04 readme.txt
[root@bogon git-repo]# git init
Initialized empty Git repository in /usr/local/git/git-repo/.git/
[root@bogon git-repo]# cd ~
[root@bogon ~]# mkdir .ssh
[root@bogon ~]# cd .ssh
[root@bogon .ssh]# ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:
8c:fa:e5:3a:a4:48:c8:fe:58:41:7f:99:5c:e6:90:8d [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
| |
| + |
| . E + |
| . . .oB |
|.. . ..=S. |
|... ..o |
|.. o.o . |
| .+ ...o |
| ... oo. |
+-----------------+
[root@bogon .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5wZoqfl3kpLnugTku4J10JhuKJLZq/0RBBfsRrO7OtBzjBjnGCBvdGY3K+2m0IMu5UGhXgdBRPMVtxKG1QlYxKEVmgQpaEpZnsXsG0wDKHsgrn3oBgD59mpdvIGOh6korJ/GBlYRF4Djw0YmtTRFTcv5Jx5AAo7lTXYkJttcm4rxFhLsXg/gZNoyBlRzH+AQXQQjajYyvnx4+dJMXxEizrebNSmVxnLyotGovCnza/jSC617ASi0AOoyrWM5RHUsvnf92LmUwk+LR6Eyz97Aa6tyl1r5G8sR0VV/k+koxKHSXxn1cxozmNPdqJZ2fLiisUp9oTa0S9I3RCqS7zAWLw== [email protected]
[root@bogon .ssh]#