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即可生效。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM