如何处理git的Auto packing

本文详细介绍了当Git仓库过大导致性能下降时的解决方案,包括如何处理dangling commit、调整配置参数以及关闭自动垃圾回收等方法。
  • 当我们的git仓库运行一段时间后,可能会很大,仓库内保存的git object过多。这时当你执行一些git命令,例如git pull,的时候就会有这样的提示:

Auto packing the repository for optimum performance. You may also
run “git gc” manually. See “git help gc” for more information.

  • 这是git是在将这些object打包成一个packfile的文件以节省空间并提高效率。一般情况下执行一下git gc就好了。

  • 这种情况一般是因为本地git的dangling commit过多(dangling commit可以通过git merge来恢复)。则可以通过下面命令解决。

    • 1 、git fsck --lost-found (查看dangling commit)
    • 2、 git gc --prune=now
  • 但有时也会报out of memory的错误:

warning: suboptimal pack - out of memory
fatal: Out of memory, malloc failed (tried to allocate 130420145 bytes)
error: failed to run repack

  • 这是可以修改.git/config文件。添加下面的内容在该文件中:
[core]
    packedGitLimit = 128m
    packedGitWindowSize = 128m

[pack]
    deltaCacheSize = 128m
    packSizeLimit = 128m
    windowMemory = 128m
  • 或者是:
[pack]
    window = 0 
  • 最后,也就是我遇到的情况,上面这些办法我都试了,可是每次执行git pull还是会Auto packing,而且这个耗时会很长。于是,只有最后的办法——关闭这个自动垃圾收集。
  • 执行命令 git config gc.auto 0
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值