github 提交原创代码出现的问题-The requested URL returned error: 403 和github Permission denied (publickey) 的问题

来源:互联网 发布:手机系统克隆软件 编辑:程序博客网 时间:2024/06/06 05:27

提交的时候出现的问题

问题1:The requested URL returned error: 403

问题2 :github Permission denied (publickey).

搜了很多资料,把步骤整理了一下,亲们可以按照步骤操作就好了。

首先需要生成本地的ssh key

1. 检查SSH keys是否存在

输入下面的命令,如果有文件id_rsa.pub 或 id_dsa.pub,则直接进入步骤3将SSH key添加到GitHub中,否则进入第二步生成SSH key
ls -al ~/.ssh# Lists the files in your .ssh directory, if they exist

2. 生成新的ssh key(网上一搜一大片。。)

第一步:生成public/private rsa key pair

在命令行中输入ssh-keygen -t rsa -C "your_email@example.com"

默认会在相应路径下(/your_home_path)生成id_rsaid_rsa.pub两个文件

第二步:将新生成的key添加到ssh-agent中:

# start the ssh-agent in the backgroundeval "$(ssh-agent -s)"Agent pid 59566ssh-add ~/.ssh/id_rsa
然后cat ~/.ssh/id_rsa.pub
全部复制(以ssh-rsa开始)添加到github 上的setting //SH and GPG keys 目录下,新建ssh_key ,名字随便起然后保存
上传成功如上图所示。。
===================================================================


接着  进入你的项目的根目录,执行以下操作

1:ssh-add -d~/ssh/id_rsa.hub

2:ssh-add -l


3:git init 

4"git add README.md

5:git commit -m "first commit"

6:打开你的项目  .git/config 文件,将文件中的

url = https://github.com/你的github的名字/JsBridge_Android.git   改为

url = ssh://git@github.com/github的名字/JsBridge_Android.git

保存并退出

7:git remote add originhttps://github.com/bbe-wang/JsBridge.git(别忘了改名称,,这个从github上抄就可以了)

8 :git push -u origin master


完事了~  希望大家都上传成功  哈哈哈  


 



阅读全文
0 0
原创粉丝点击