今天我提交代码到我的git服务器上,结果,总是报错,折腾了一下午,结果才解决。


首先看看我提交代码的时候,报错的信息:


git.exe push --progress "origin" master:master


Counting objects: 43142, done.

Delta compression using up to 8 threads.

Compressing objects: 100% (25108/25108), done.

Writing objects: 100% (43142/43142), 824.64 MiB | 26.18 MiB/s, done.

Total 43142 (delta 14030), reused 43141 (delta 14030)

fatal: The remote end hung up unexpectedly

fatal: The remote end hung up unexpectedly

error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large

Everything up-to-date



git did not exit cleanly (exit code 1) (717417 ms @ 2016/11/1 15:57:57)


 网上搜了一下,我以为跟上次我pull的时候报错git clone: error: RPC failed; result=18, HTTP code = 200 解决办法的解决方法一样哦,结果我始终修改http.postBuffer的大小,改大改小都试过,但提交到一定大小以后,老是会出现上述的报错信息。


后面结合http://stackoverflow.com/questions/7489813/github-push-error-rpc-failed-result-22-http-code-413中的内容,以及http://blog.csdn.net/passion_wu128/article/details/8234901博文的内容,我了解到上述的这种报错:


这跟Git的postBuffer变量值没有关系。


(如果code = 411,则是由postBuffer引起的,可以在客户端执行


git config --global http.postBuffer 52428800,改为最大50M)


 


解决方法其实能通过ssh提交来解决,所以实在没办法,我使用ssh来提交,而不用之前的http方法,最后证明可行。


 


这里记录下使用ssh提交代码和生成公钥的过程。


这个过程,我借鉴http://www.cnblogs.com/ChenRihe/p/Git_TortoiseGit_SSH.html的部分内容做参考:


1.如果没配置过用户名和密码(配过也再来一次咯):


git config --global user.name "John Doe"

git config --global user.email "johndoe@doebrothers.com"


2.创建SSH和复制公钥到剪切板(如复制以下代码执行出现参数过多提示,一般由于字符问题,需自己手打以下代码)


ssh-keygen –t rsa –C "johndoe@doebrothers.com"


clip < ~/.ssh/id_rsa.pub


3.生成ssh公钥以后,我们先cat一下公钥,在git bash中输入cat ~/.ssh/id_rsa.pub,这个时候会显示出我们生成的公钥,这时候拷贝公钥,在我们git的账户中添加ssh就OK。


4.设置remote url,在git bash中输入:


git remote set-url origin git@github.com:GitRepoName.git

github.com是你的服务器域名,例如你用开源中国的码云的话,这个地方就是git@git.oschina.net


GitRepoName.git是git仓库名。


5.提交代码,git push origin master


使用ssh提交代码,比使用http不但能解决413的大文件报错,同时还能提高提交代码的速度,从我提交的速度来看,他最少能够提升100%的速度,所以还是使用ssh吧。


 


友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信