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

简介: 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](https://my.oschina.net/u/3749391):host/xxxx项目

如下配置:

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

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

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

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

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



目录
相关文章
|
22天前
|
Ubuntu Linux Shell
github用存在的私钥在Linux上配置免密登录
在Linux上配置GitHub免密登录,使用已有的私钥。系统环境为Ubuntu 22.04.3 LTS。步骤包括:1) 将名为`github`的私钥文件上传至`~/.ssh/github`;2) 设置正确权限`chmod 600 ~/.ssh/github`和`chmod 700 ~/.ssh`;3) 启动SSH代理并添加私钥`ssh-agent -s`和`ssh-add ~/.ssh/github`。完成上述步骤后,可以无缝使用GitHub。
29 0
|
3天前
|
Linux 测试技术 开发工具
CentOS Linux 8使用阿里源(安装jdk11、git测试)
CentOS Linux 8使用阿里源(安装jdk11、git测试)
14 1
|
4天前
|
JavaScript Ubuntu Linux
蓝易云 - linux中安装nodejs,卸载nodejs,更新nodejs,git
请根据自己的Linux发行版和版本选择合适的命令。
12 2
|
12天前
|
Linux 网络安全
|
17天前
|
存储 开发工具 git
解决“hint: the same ref. If you want to integrate the remote changes, usehint: ‘git pull‘ before pus”
解决“hint: the same ref. If you want to integrate the remote changes, usehint: ‘git pull‘ before pus”
|
24天前
|
缓存 开发工具 数据安全/隐私保护
mac git命令行操作 git push pull 逻辑
mac git命令行操作 git push pull 逻辑
18 1
|
2天前
|
网络安全 开发工具 数据安全/隐私保护
git pull/push每次都需要输入密码问题
git pull/push每次都需要输入密码问题
17 0
|
1月前
|
开发工具 git
git pull之后出现REBASE(1/1)
git pull之后出现REBASE(1/1)
33 3
|
1月前
|
开发工具 git
Git的安装与卸载
该内容是关于如何下载Git的指导。首先,访问Git的官方网站[https://git-scm.com/downloads](https://git-scm.com/downloads)来获取相应平台的下载选项。然后,选择适合的安装包进行下载。文中包含三个图片,分别展示了下载页面、选择安装包的步骤以及可能的安装程序界面。
|
1月前
|
JSON 安全 网络协议
【Linux 网络】网络基础(二)(应用层协议:HTTP、HTTPS)-- 详解
【Linux 网络】网络基础(二)(应用层协议:HTTP、HTTPS)-- 详解