git clone时报错:
10:23:54 remote: Counting objects: 512376, done.
10:23:58 remote: Compressing objects: 100% (357372/357372), done.
11:36:04 remote: Total 512376 (delta 119614), reused 512376 (delta 119614)
11:36:04 Receiving objects: 100% (512376/512376), 6.74 GiB | 1.60 MiB/s, done.
11:36:21 Resolving deltas: 100% (119614/119614), done.
11:37:02 error: inflate: data stream error (incorrect data check)
11:37:02 error: inflate: data stream error (incorrect data check)
11:37:02 fatal: packed object 42a8629df252c10f6e6e3a19ad89307405a45a4f (stored in .git/objects/pack/pack-3c607af44e7a818dfb7f8ff535a6fc2ea675cc59.pack) is corrupt
11:37:02 warning: Clone succeeded, but checkout failed.
11:37:02 You can inspect what was checked out with ‘git status’
11:37:02 and retry the checkout with ‘git checkout -f HEAD’
检查$ git fsck --full
00:44:54 Checking object directories: 100% (256/256), done.
00:45:21 error: .git/objects/pack/pack-3c607af44e7a818dfb7f8ff535a6fc2ea675cc59.pack SHA1 checksum mismatch
00:47:02 error: index CRC mismatch for object 3467975a9229614d11616b86e3cf2e403ee4bad0 from .git/objects/pack/pack-3c607af44e7a818dfb7f8ff535a6fc2ea675cc59.pack at offset 6001461490
00:47:02 error: inflate: data stream error (incorrect data check)
00:47:02 error: cannot unpack 3467975a9229614d11616b86e3cf2e403ee4bad0 from .git/objects/pack/pack-3c607af44e7a818dfb7f8ff535a6fc2ea675cc59.pack at offset 6001461490
00:47:18 Checking objects: 100% (512376/512376), done.
查看原因:
$ free -m
14:11:19 total used free shared buff/cache available
14:11:19 Mem: 7966 75 324 6 7566 7546
14:11:19 Swap: 1021 3 1018
发现剩下能用的内存太少,用下面方法解决:
sync
sudo echo 3 > /proc/sys/vm/drop_caches
查看结果如下:
free -m
14:39:11 total used free shared buff/cache available
14:39:11 Mem: 7966 76 7824 6 64 7705
14:39:11 Swap: 1021 3 1018
再clone
14:44:15 remote: Counting objects: 512376, done. 14:44:52 remote: Compressing objects: 100% (357684/357684), done. 14:57:29 remote: Total 512376 (delta 119622), reused 511847 (delta 119302) 14:57:29 Receiving objects: 100% (512376/512376), 6.74 GiB | 9.13 MiB/s, done. 14:57:46 Resolving deltas: 100% (119622/119622), done. 15:06:39 Checking out files: 100% (557039/557039), done.
问题解决了。
为什么内存剩下这么少呢? 一开始git clone时连接中断报错,占用了cache没有释放。而我的git仓库大小是8G,cache直接就到了8G,所以内存一次就耗尽了。