Git 提交大文件提示 fatal: The remote end hung up unexpectedly

使用gitlab搭建的git server,如果直接使用http的方式去提交的话,提交小文件不会有问题,但是提交大文件时,会出错: fatal: The remote end hung up unexpectedly。

解决办法就是使用ssh提交。

windows下解决方法:

打开git bash

Step1:

ssh-keygen -t rsa -C "YOUREMAIL@DOMAIN.COM"#根据你的邮箱生成一个sshkey

生成成功后,在本地会保存一个私钥,然后将公钥放到gitlab上:
Step2:
cat ~/.ssh/id_rsa.pub
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....

就是将ssh-rsa...一串代码粘贴到sshkeys中。

Step3:
修改git 的url为git@server:username/project.git
git remote set-url origin git@gitserver:USERNAME/PROJECT.git

然后再去提交,就可以成功了。


#############提交附件时,如果超过10M,会无法提交###################################
这样解决: 修改gitlab下的models/note.rb文件,将其中对文件大小的限制由10m修改为指定大小:

vim /opt/gitlab-6.3.0-0/apps/gitlab/htdocs/app/models/note.rb

找到如下行:validates :attachment, file_size: { maximum: 10.megabytes.to_i }

将10修改为100M

validates :attachment, file_size: { maximum: 100.megabytes.to_i }

如果httpserver使用提nginx,则修改配置文件nginx.conf,在http中加入 client_max_body_size 50m, 这个值默认是1M。

如果http server使用的是apache,则修改配置文件httpd.conf,在最后一行加入指令:LimitRequestBody 2147483647

(RequestBody在byte为单位,上面的指令为允许最大上传2G的文件。

修改完成后,重启gitlab和httpserver即可生效。

原文地址:https://www.cnblogs.com/hanxianlong/p/3464224.html