由于网络波动,使用的是gitLab HTTP协议来提交的代码,在提交代码时会发生提交的文件在服务端损坏的情况,这个时候客户端应为这个文件损坏而无法pull代码,报错如下:
git -c diff.mnemonicprefix=
false -c core.quotepath=
false -c credential.helper=sourcetree fetch ebs-biz-evaluation
2017-
08-
24 17:
07:
49.955 git-credential-sourcetree[
8431:
133862] Error (internetKeychainItemForServer:withUsername:path:port:protocol:) - The specified
item could
not be found
in the keychain.
warning: no common commits
remote:
error: inflate: data stream
error (incorrect data check)
remote:
error: corrupt loose object '
256183692dc917ae201eaa863b157e1e0b9d68f3'
remote: fatal: loose object
256183692dc917ae201eaa863b157e1e0b9d68f3 (stored
in ./objects/
25/
6183692dc917ae201eaa863b157e1e0b9d68f3)
is corrupt
remote: aborting due
to possible repository corruption
on the remote side.
fatal: protocol
error: bad pack header
Completed
with errors, see
above
各方面查找资料没有符合自己的有效方案,最终通过自己的理解解决,解决方案如下:
1、进入服务器跟目录(这一步很重要)
cd /
2、查出问题项目的仓库目录
find -name test.git(这里举例为test.git,在知道目录的情况下这一步可以省略)
3、修改gitlab目录下git-data的权限
chmod -R 777 git-data/(默认情况下这个是没有权限可写)
4、进入仓库目录报错的文件对应的文件夹
在git目录下找到objects文件并进入(git提交的文件都会以一个hash值为名字的文件存储在objects目录下)
5、文件替换
找到最后提交代码的开发人员本地仓库找到对应的损坏的文件上传至服务器对应的覆盖文件即可,这里报错的文件目录为./objects/25/6183692dc917ae201eaa863b157e1e0b9d68f3