文章来源
https://blog.csdn.net/dzhongjie/article/details/81152983
https://blog.csdn.net/qq_41629150/article/details/97250690
常用命令
1、git base提交本地仓库代码到github
git remote add origin https://github.com/DemoTransfer/webmanager.git(github项目地址)
git pull origin master 拉取
git push -u origin master 推送
2、git本地仓库新增文件
git add readme.txt
git commit -m "wrote a readme file"
3、设置git的代理服务器
git项目时,有时速度比较慢,可以设置--depth=1,只要最后一个版本的代码,而不要.git目录中的东西
git clone --depth=1 https://github.com/Project-OSRM/osrm-backend.git
git config --global http.proxy http://127.0.0.1:8580
git config --global https.proxy https://127.0.0.1:8580
git config --global http.SSLVERIFY false
问题记录
1、使用git clone命令克隆文件出现error: RPC failed; curl 18 transfer closed with outstanding read data remain问题
在使用git clone命令从github克隆源码到电脑时出现了以下问题:
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
究其原因是因为curl的postBuffer的默认值太小,我们需要调整它的大小,在终端重新配置大小
在这里,笔者把postBuffer的值配置成500M,对笔者来说已经够了。可以根据你需要下载的文件大小,将postBuffer值配置成合适的大小。
git config --global http.postBuffer 524288000
这样已经配置好了,如果你不确定,可以根据以下命令查看postBuffer。
git config --list
若设置缓冲区大小无用的情况下,再对下载时间配置信息变更:
git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999
增加最低速度时间,上述配置方法适应与网络比较慢的情况下使用。
2、git clone错误之"error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054"
当我们使用git clone指令从github 上download其它优秀的代码时,如果报如下错误
RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
这是因为服务器的SSL证书没有经过第三方机构的签署,所以才报错。解决方案如下:
第一步,克隆远程仓库时,用env命令设置GIT_SSL_NO_VERIFY环境变量为”ture”,并同时调用正常的git clone命令。完整的命令如下:
env GIT_SSL_NO_VERIFY=true git clone https://<host_name/git/project.git
第二步,在克隆完毕的仓库中将http.sslVerify设置为”false”。完整的命令如下:
git config http.sslVerify "false"
备注:以上方法应该是Git处理可信任的SSL临时证书很好的方法,第一步使用env命令保证了忽略证书错误是单次行为,不会成为默认的设置。第二次,则把忽略证书错误的设置限定在特定的仓库,避免扩大该设置的适用范围而引起的潜在安全风险。