为什么git会在每次推送到我们的回购库时运行自动包装? [英] Why does git run auto-packing on every push to our repo?

查看:105
本文介绍了为什么git会在每次推送到我们的回购库时运行自动包装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去几天,每次推送到我们的git存储库都会导致服务器自动打包。



客户端发生这种情况时的输出:

 〜pdr git:master❯❯❯git push origin master 
计数对象:44,完成。
使用多达8个线程的增量压缩。
压缩对象:100%(26/26),完成。
写作对象:100%(27/27),4.67 KiB,完成。
总计27(增量14),重用0(增量0)
自动打包存储库以获得最佳性能。

包装发生在服务器上,ps显示了这些git命令:

  git 23252 0.0 0.0 68520 552? S 15:21 0:00 sshd:git @ notty 
git 23253 0.0 0.0 9660 540? Ss 15:21 0:00 git shell -c git-receive-pack'repositories / pdr.git'
git 23254 0.0 0.0 16644 2136? S 15:21 0:00 git receive-pack repositories / pdr.git
git 23258 0.0 0.0 9660 624? S 15:21 0:00 git gc --auto --quiet
git 23261 0.0 0.0 9660 504? S 15:21 0:00 git repack -d -l -q -A
git 23262 0.0 0.0 4104 376? S 15:21 0:00 / bin / sh / usr / lib / git-core / git-repack -d -l -q -A
git 23275 267 92.2 9569724 3742468? Sl 15:21 23:07 git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog --unpack -reachable --local -q --delta- base-offset /home/git/repositories/pdr.git/objects/.tmp-23262-pack

我在服务器上运行了一个手动的git gc,后面跟着一个git fsck。没有错误信息,但在下一次推送时它又开始自动打包。



这是运行Ubuntu Server 10.04 LTS并使用Gi​​t 1.7.0.4的服务器。

解决方案

Git决定是否自动gc 基于两个标准


  1. 包太多了? (从字面上看,是否有超过50个文件< a> with .idx 位于 .git / objects / pack ?)

  2. 是否有太多松散的物体? (从字面上看,有超过27个文件< code $ .git / objects / 17 ?)

原因Git无法合并包文件或删除该目录中的松散对象,它会认为它需要在下次自动gc。



我会检查上面列举的两个目录的内容,看看是否符合(默认)条件,并且看看重新包装后标准是否改变。



完成该过程可能是:

$ ul

  • 某种权限问题
  • 无法访问的对象被忽略Git的垃圾收集或由于他们年轻而未被默认修剪

  • 磁盘空间不足以完成gc(重新包装) b $ b
  • gc(重新包装)

  • 对象太大而不适合指定的包装大小(请参阅 git config pack.packSizeLimit ,默认为无限制,但可能被用户覆盖)



  • 您当然也应该确保gc相关的可调参数没有被不合理地设置:

    pre $ git config -l | grep gc

    有关其他细节,请参阅 Git Internals


    The last few days, each and every push to our git repository has caused auto-packing on the server.

    The output on the client when this happens:

    ~pdr git:master ❯❯❯ git push origin master
    Counting objects: 44, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (26/26), done.
    Writing objects: 100% (27/27), 4.67 KiB, done.
    Total 27 (delta 14), reused 0 (delta 0)
    Auto packing the repository for optimum performance.
    

    The packing happens on the server, and ps shows these git commands at work:

    git      23252  0.0  0.0  68520   552 ?        S    15:21   0:00 sshd: git@notty  
    git      23253  0.0  0.0   9660   540 ?        Ss   15:21   0:00 git shell -c git-receive-pack 'repositories/pdr.git'
    git      23254  0.0  0.0  16644  2136 ?        S    15:21   0:00 git receive-pack repositories/pdr.git
    git      23258  0.0  0.0   9660   624 ?        S    15:21   0:00 git gc --auto --quiet
    git      23261  0.0  0.0   9660   504 ?        S    15:21   0:00 git repack -d -l -q -A
    git      23262  0.0  0.0   4104   376 ?        S    15:21   0:00 /bin/sh /usr/lib/git-core/git-repack -d -l -q -A
    git      23275  267 92.2 9569724 3742468 ?     Sl   15:21  23:07 git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog --unpack-unreachable --local -q --delta-base-offset /home/git/repositories/pdr.git/objects/.tmp-23262-pack
    

    I have run a manual "git gc" followed by a "git fsck" on the server. No error messages, but on the next push it started auto-packing again.

    This is on a server running Ubuntu Server 10.04 LTS with Git 1.7.0.4.

    解决方案

    Git decides whether to auto gc based on two criteria:

    1. Are there too many packs? (Literally, are there more than 50 files with .idx in .git/objects/pack?)
    2. Are there too many loose objects? (Literally, are there more than 27 files in .git/objects/17?)

    If for some reason Git is not able to merge the pack files or remove the loose objects in that directory, it will think it needs to auto-gc again next time.

    I would check the contents of the two directories cited above to see if the (default) criteria are met and see if the criteria change after the re-packing.

    Some reasons for failure to complete the process might be:

    • some sort of permissions problem
    • unreachable objects that are ignored by Git's garbage collection or not pruned by default due to their youth
    • insufficient disk space to complete the gc (the repack)
    • insufficient memory to complete the gc (the repack)
    • objects too large to fit in a specified pack size (see git config pack.packSizeLimit which defaults to unlimited but may be overridden by the user)

    You should also ensure of course that the gc related tunable parameters haven't been set unreasonably by looking at:

    git config -l | grep gc
    

    For some other details, see the Git SCM book on Git Internals.

    这篇关于为什么git会在每次推送到我们的回购库时运行自动包装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆