github初试-403错误

在申请完github账号,(申请及创建可以参考下面的资料链接)并创建好项目提交代码时出现了403的错误。

错误代码如下:

error: The requested URL returned error: 403 while accessing https://github.com/hanxiangduo/workdoc.git/info/refs

fatal: HTTP request failed

在github上创建好项目后,会生成一个项目路径,按照github上的说法,http和ssh均有读写的权限Read+Write access。

但是实际上github暂不支持http的读写权限,需要以ssh的方式进行项目的提交。

我建的这个测试项目的http路径是:https://github.com/hanxiangduo/axis2c-test.git

通过git clone到本地后,在.git/config文件中可以看到该项目路径信息。

因此需要将项目路径由http修改为ssh以获取读写权限。

可通过下面方式修改:

git remote set-url origin ssh://git@github.com/hanxiangduo/axis2c-test.git

这个ssh的地址可以从建好的项目中取得。不过需要稍作修改。

改动如下:

其中如果直接从github中迁出地址git@github.com:hanxiangduo/axis2c-test.git

会出现下面的错误

ssh: Could not resolve hostname github.com:hanxiangduo: Name or service not known
fatal: The remote end hung up unexpectedly

将冒号修改为"/"斜杠就行了就可以了。

修改完成就可以远程push了。

参考这里的一些资料

如何为github账户添加ssh key:http://chinacheng.iteye.com/blog/1173838

详细的github申请配置流程:http://wuyuans.com/2012/05/github-simple-tutorial/

stackoverflow上对提交github权限不足的解决方法:http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed

 

posted on 2012-09-03 17:11  hanxiangduo  阅读(7180)  评论(1编辑  收藏  举报

导航