Linux 安装git管理服务器项目

  • 删除系统自带的git
yum remove git
wget https://github.com/git/git/archive/v2.21.0.tar.gz
  • 安装依赖
yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
  • 解压
tar -zxvf v2.21.0.tar.gz
  • 进入解压目录
cd git-2.21.0/
  • 编译
make prefix=/usr/local/git all
  • 安装
make prefix=/usr/local/git install
  • 编辑环境配置文件()
vim /etc/profile
# 末尾添加
export PATH=$PATH:/usr/local/git/bin
  • 使之生效
source /etc/profile
  • 查看git版本
git --version
  • 全局配置用户名
git config --global user.name "nameVal"
  • 全局配置邮箱
git config --global user.email "eamil@qq.com"
  • 配置编码
 git config --global core.autocrlf false
 git config --global core.quotepath false 
 git config --global gui.encoding utf-8

git 公钥配置

  • 在终端输入
ssh-keygen -t rsa -C "xx@163.com"
  • 一路回车,不要输入任何密码之类,生成ssh key pair (以下包含公钥和私钥,若只需要公钥,可直接查看)
  • ssh-add ~/.ssh/id_rsa

   如果出现 Could not open a connection to your authentication agent.

  • 执行
 eval `ssh-agent`

  出现

Agent pid 14578
  • 再执行
ssh-add ~/.ssh/id_rsa

  此时出现

Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
  • 查看公钥
cat ~/.ssh/id_rsa.pub

  出现的一串字符串填入git

  此时可以使用 SSH 克隆代码

git clone git@github.com:xxx/xxx.git


作者:席坤
链接:https://www.jianshu.com/p/2df3b3cfbc76
来源:简书

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值