Linux 安装git,并且使用https方式 git pull 代码的免密操作

  • 删除系统自带的git

    yum remove git

  • 安装依赖

    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=/usr/local/git/bin

  • 使之生效

    source /etc/profile

  • 查看git版本

    git --versiob

  • 全局配置用户名

    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

\=========================================================================

使用这中http方式 拉去代码时 git clone http://username@ip:host/xxxx项目

如下配置:

进入服务器的项目目录,执行

[root@slave5 ~]# git config --global credential.helper store

执行之后,继续项目代码路径git pull

[root@slave5 BigData.XNYKDX.ETL]# git pull

重新输入一遍账号密码。然后往后就不需要再输入了

Buy me a cup of coffee :)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值