linux安装git,要通过root用户进行安装
一.编译安装步骤如下
1.安装依赖的包
yum update
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
2.下载git源码并解压缩
#卸载旧版本git
yum remove git
wget https://github.com/git/git/archive/master.zip
unzip git-master.zip
cd git-master
3.编译安装
make prefix=/usr/local/git all
make prefix=/usr/local/git install
4.将git安装路径添加到PATH变量
vi /etc/profile
#在最后一行添加 export PATH=/usr/local/git/bin:$PATH 保存退出
5.验证是否安装成功
source /etc/profile
git --version
二.通过yum安装
1.直接通过命令行安装
yum install git
2.查看安装版本
root@zph-IdeaCentre-GeekPro-14IOB:/home/zph# git --version
git version 2.25.1
三.配置git
#全局配置用户名,邮箱
git config --global user.name "username"
git config --global user.email "user@mail.com"
1.使用www用户和github连接
本地git和远程github链接:
https://help.github.com/articles/generating-ssh-keys/
(1).切换到www用户下
(2).检测ssh的keys是否存
ls -al ~/.ssh
结果:
id_dsa.pub
id_ecdsa.pub
id_ed25519.pub
id_rsa.pub
说明已经存在ssh的keys, 如果没有存在就使用以下的命令进行生成ssh的key
(3).生成ssh的key
ssh-keygen -t rsa -b 4096 -C "user@mail.com"
按三次回车即可
(4). 需要将key作为ssh的代理
生成代理代理的pid
eval "$(ssh-agent -s)"
将ssh的key作为代理
(5). 需要将生成ssh的key保存到github的账号上(将ssh和github联系起来)
5.1 注册和登陆github
5.2 查看ssh的key值
cat ~/.ssh/id_rsa.pub
5.3 到ssh的key添加界面
https://github.com/settings/ssh
5.4 将ssh的key添加到界面中
5.5 测试ssh和github是否联通
ssh -T git@github.com