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

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



目录
相关文章
|
1月前
|
存储 Shell Linux
【Shell 命令集合 文件管理】Linux git命令使用教程
【Shell 命令集合 文件管理】Linux git命令使用教程
34 0
|
1月前
|
开发工具 git 开发者
|
1月前
|
开发工具 git 开发者
Git Pull vs. Git Fetch:深度解析
【2月更文挑战第29天】
132 0
Git Pull vs. Git Fetch:深度解析
|
1月前
|
开发工具 git C++
【git 实用指南】git下载、拉取 代码
【git 实用指南】git下载、拉取 代码
180 2
|
1月前
|
开发工具 git
【git 实用指南】git 上传代码
【git 实用指南】git 上传代码
34 2
|
30天前
|
Linux 编译器 程序员
【Linux 调试秘籍】深入探索 C++:运行时获取堆栈信息和源代码行数的终极指南
【Linux 调试秘籍】深入探索 C++:运行时获取堆栈信息和源代码行数的终极指南
68 0
|
1月前
|
安全 Linux 开发者
⭐⭐⭐⭐⭐Linux C/C++ 进程崩溃诊断以及有效数据收集:解锁代码问题快速定位与修复的方法
⭐⭐⭐⭐⭐Linux C/C++ 进程崩溃诊断以及有效数据收集:解锁代码问题快速定位与修复的方法
83 1
|
2天前
|
Linux 开发工具 C语言
【linux基础(七)】Linux中的开发工具(下)--make/makefile和git
【linux基础(七)】Linux中的开发工具(下)--make/makefile和git
|
6天前
|
开发工具 git
git 拉取代码仓库代码报错(合并错误 refusing to merge unrelated histories)
git 拉取代码仓库代码报错(合并错误 refusing to merge unrelated histories)
15 0
|
10天前
|
数据可视化 开发工具 git
Git代码版本管理入门
Git代码版本管理入门