git push失败的一次经验总结
报错日志
git push 失败的日志
$ git push
Enumerating objects: 27432, done.
Counting objects: 100% (27432/27432), done.
Delta compression using up to 4 threads
Compressing objects: 100% (12287/12287), done.
Writing objects: 100% (27431/27431), 1.18 GiB | 20.36 MiB/s, done.
Total 27431 (delta 6495), reused 27429 (delta 6494)
remote: Resolving deltas: 100% (6495/6495), completed with 1 local object.
remote: Checking connectivity: 27431, done.
remote: GitLab: Push operation timed out
remote:
remote: Timing information for debugging purposes:
remote: Running checks for ref: master
remote: Checking if you are allowed to push... (4.04ms)
remote: Checking if default branch is being deleted... (11.72ms)
remote: Scanning repository for blobs stored in LFS and verifying their files have been uploaded to GitLab... (cancelled after 29152.58ms)
To gitlab.example.com:xxx/commonlibs.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitlab.example.com:xxx/commonlibs.git'
背景描述
- 本地的maven仓库放在了自己搭建的gitlab服务器(在本地虚拟机)上
- 推送分支是master
- 本地有较长的时间没有往服务端推送信息,导致本次push的数据量较大(1GB左右)
- 之前push是没有问题,本次push总是报错
问题分析
- 由于push的分支是master,有可能master为受保护的分支,自己没有权限。
- 分析:历史原因(之前在master分支推送是没有问题的)证明权限没有问题,并且在gitLab中检查了自身的权限,具有push的权限。
- 结论:自身具备往master分支push的权限,现在push失败跟权限没关系
- 往该gitLab服务器的其他仓库push数据时是成功的
- 分析:往其他仓库push成功的例子都是数据量小的时候
- 结论:可能跟数据量大有关系
- 观察本地gitLab服务器所在的虚拟机配置:2核2G内存,配置较低,有时操作都很卡
- 分析:可能跟虚拟机的配置低有关系,
- 结论:配置低导致push时gitLab处理超时,从而push失败。
- 调大虚拟机配置:2核4GB内存
- 分析:push成功
- 结论:确实是虚拟机配置低导致push失败!
结论
该问题属于偶发性问题,只有在虚拟机配置低(导致gitLab服务器处理数据过慢)、push数据量大且文件细小时才会出现。
但是该问题也属于比较典型的问题,故记录下来供学习。
git push 成功的日志
$ git push --set-upstream origin testPushError
Enumerating objects: 27432, done.
Counting objects: 100% (27432/27432), done.
Delta compression using up to 4 threads
Compressing objects: 100% (12287/12287), done.
Writing objects: 100% (27431/27431), 1.18 GiB | 20.48 MiB/s, done.
Total 27431 (delta 6495), reused 27429 (delta 6494)
remote: Resolving deltas: 100% (6495/6495), completed with 1 local object.
remote:
remote: To create a merge request for testPushError, visit:
remote: http://gitlab.example.com/xxx/commonlibs/merge_requests/new?merge_request%5Bsource_branch%5D=testPushError
remote:
To gitlab.example.com:xxx/commonlibs.git
* [new branch] testPushError -> testPushError
Branch 'testPushError' set up to track remote branch 'testPushError' from 'origin'.