在申請完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均有讀寫的權限R 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