Git:如何重新包装所有松散的提交 [英] Git: how to repack all loose commits

查看:117
本文介绍了Git:如何重新包装所有松散的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 git gc git repack (有各种选项)后,我仍然有4825个宽松提交放入文件夹 .git / objects 中。我想将所有这些文件放在包文件中与其他包或其他包文件中。



我正在做很多提交重写(修改+ rebase),因此有许多不可达的提交是完全正常的。我的.gitconfig包含这些参数来保持reflogs和无法访问的提交很长一段时间。

  [gc] 
reflogExpire = 300天
reflogExpireUnreachable = 200天
pruneExpire = 90天

您可能想知道如果它是有道理的,但我已经需要并已经恢复了几个月前提出的一些提交。发生这种情况的原因是,我们在一组新的高优先级分支上开发了好几个月,然后继续在较低优先级的分支上继续工作。



这个问题的主要原因是 git gui 一直在抱怨压缩我的数据库despites我已经完成了多次。
如果我们无法打包那些松散的提交,那么这个抱怨可能是 git gui 中的一个错误。

解决方案

git-gui的警告只是提示您可能想要进行一些维护。对于大多数拥有大量物品的人来说,它们正在放慢速度。在你的情况下,你应该禁用该警告。有问题的函数是 hint_gc ,它在git-gui脚本文件结尾处被调用。

  if if {[is_enabled multicommit]} {
#after 1000 hint_gc
}

多笔业务是一个标志,用于确定我们是以committool还是通用应用程序。

如果你想在别处正常使用git-gui,那么你可以添加一个respository特定的标志。例如:

  if if {[is_enabled multicommit]&& ![is_config_true gui.skip_gc_warning]} {
after 1000 hint_gc
}

应该允许您使用 git config --bool gui.skip_gc_warning true 以每个存储库为基础禁用该功能。


After using git gc and git repack (with various options) I still have 4825 loose commits in the folder .git/objects. I would like to have all of them in the pack file with the rest or in another pack file.

I'm doing lots commit rewriting (amend + rebase) hence it's perfectly normal to have many unreachable commits. My .gitconfig contains these parameters to keep reflogs and unreachable commits for a long time.

[gc]
    reflogExpire = 300 days
    reflogExpireUnreachable = 200 days
    pruneExpire = 90 days

You may wonder if it make sense but I already needed and have recovered a few commits made several months ago. It happens we develop for many months on a new set of higher priority branches and afterwards continue on the older lower priority branches.

The main reason for this question is that git gui keeps on complaining to compress my database despites I have done this many times. If we are not able to pack those loose commits then this "complaining" might be a bug in git gui.

解决方案

The warning from git-gui is just a hint that you might want to do some maintenance. For most people having a high number of objects is just slowing them down. In your case, you should disable the warning. The function in question is hint_gc and it is called from near the end of the git-gui script file. Just comment it out as below.

if {[is_enabled multicommit]} {
        #after 1000 hint_gc
}

The multicommit business is a flag that determines if we are running as committool or a general purpose app.

If you want to use git-gui normally elsewhere, then you could add a respository specific flag instead. Something like:

if {[is_enabled multicommit] && ![is_config_true gui.skip_gc_warning]} {
        after 1000 hint_gc
}

should let you use git config --bool gui.skip_gc_warning true to disable that on a per-repository basis.

这篇关于Git:如何重新包装所有松散的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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