博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【git搭建】创建本地仓库与github(远程仓库)的传输
阅读量:7119 次
发布时间:2019-06-28

本文共 1793 字,大约阅读时间需要 5 分钟。

hot3.png

本地Git仓库和github仓库之间的传输是通过SSH加密传输的

1. 生成密钥

ssh-keygen -t rsa -b 4096 -C "youremail@example.com"

宿主目录 /用户/username/.ssh/目录下,会生产 id_rsa.pub(公钥) 和id_rsa(密钥) 两个文件

2. ssh代理: ssh-agent

ssh-agent是一个密钥管理器。运行ssh-agent以后,使用ssh-add将私钥交给ssh-agent保管,其他程序需要身份验证的时候可以将验证申请交给ssh-agent来完成整个认证过程。

# eval `ssh-agent -s` :启动代理,直接启动一个 ssh-agent 进程eval `ssh-agent -s`  #这里是反引号ssh-add –l

3. 在远程仓库李配置公钥

登录github,打开”settings”中的SSH Keys页面,然后点击“Add SSH Key”,填上任意title,在Key文本框里黏贴id_rsa.pub文件的内容。

4. 进行同步的时候可能遇到的问题

  • 问题1.fatal: HTTP request failed , 403 Forbidden!

如: error: The requested URL returned error: 403 Forbidden while accessing

可以看见可能是权限问题导致

解决方法:

可以修改.git/config文件追加用户名和密码:1)编辑.git/config文件2)在[remote “origin”]下找到找到url变量3)修改url = https://github.com/user/test.git,修改为url = ssh://git@github.com/user/test.git,修改完了保存
  • 问题2: 测试连接远程仓库报错

输入命令:进行测试

ssh git@github.com

可能报错:

The authenticity of host 'github.com (192.30.252.131)' can't be established.RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.Are you sure you want to continue connecting (yes/no)? yes    #这里写 yesWarning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of known hosts.Permission denied (publickey).

说是主机密钥验证失败, 发现是缺少了 known_hosts 文件, 而且必须生成 github.com 的ip执行内容.

  • 问题3: push到github时,每次都要输入用户名和密码的问题

原因:可能使用的https 方法,而非 shell方式

解决方式:查看远程仓库信息

git remote -vorigin https://github.com/yuquan0821/demo.git (fetch)origin https://github.com/yuquan0821/demo.git (push)

把https换成shell方式

git remote rm origin git remote add origin git@github.com:yuquan0821/demo.gitgit push origin``- 问题4: 推送时报邮箱错误错误信息:remote: error: GH007: Your push would publish a private email address.解决方法:在GitHub的你账号网页上右上角,个人的登录退出的位置,找到setting:    setting->emails->Keep my email address private,把这一项去掉勾选即可。

转载于:https://my.oschina.net/u/3683692/blog/3026965

你可能感兴趣的文章
【C语言】学习笔记4——数组
查看>>
Vue.js
查看>>
Codeforces 349B - Color the Fence
查看>>
mysql分组查询前n条数据
查看>>
db2表空间自动扩展
查看>>
用Vue来实现音乐播放器(十七):歌手页右侧快速入口实现
查看>>
比原空投问答题库题解(一)
查看>>
[NOI2016]区间
查看>>
最大子数组问题
查看>>
HTTP-web服务器接收到client请求后的处理过程(很详细)
查看>>
面向对象进阶
查看>>
Mininet系列实验(三):Mininet命令延伸实验扩展
查看>>
CSS设计模式之三权分立模式篇
查看>>
centos6.5 mysql安装+远程访问+备份恢复+基本操作+卸载
查看>>
linux nadianshi
查看>>
Java 的静态代理 动态代理(JDK和cglib)
查看>>
【转载】Express、Koa、Hapi框架对比
查看>>
hdu 5111 树上求交
查看>>
ubuntu server 安装 mantis bug tracker 中文配置
查看>>
HTTP请求415错误 – 不支持的媒体类型(Unsupported media type)
查看>>