Git:如何重新打包所有松散的提交

发布于 2024-12-18 06:25:41 字数 581 浏览 1 评论 0原文

使用 git gcgit repack (使用各种选项)后,我在文件夹 .git/objects< 中仍然有 4825 个松散提交 /代码>。我想将所有这些都放在包文件中以及其余的或另一个包文件中。

我正在进行大量提交重写(修改+变基),因此有许多无法访问的提交是完全正常的。我的 .gitconfig 包含这些参数来长时间保留引用日志和无法访问的提交。

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

您可能想知道这是否有意义,但我已经需要并恢复了几个月前所做的一些提交。碰巧我们在一组新的较高优先级分支上开发了几个月,然后继续在旧的较低优先级分支上开发。

这个问题的主要原因是 git gui 不断抱怨压缩我的数据库,尽管我已经这样做了很多次。 如果我们无法打包那些松散的提交,那么这个“抱怨”可能是 git gui 中的一个错误。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若无相欠,怎会相见 2024-12-25 06:25:41

考虑到 git bundle 仅用于处理打包对象(调用 fetch-pack),您尝试过捆绑,然后克隆您的存储库?

git bundle create aBundle --all # hopefully package everything, 
                                # the result being *one* file.
git clone aBundle newRepo       # recreate a full repo
# check if the cloned repo contains only packaged object

如果这有效,您可以继续使用新的克隆存储库作为您的主存储库。

Considering that git bundle is used to work with packaging objects only (calling fetch-pack), did you try to bundle, and then clone your repo?

git bundle create aBundle --all # hopefully package everything, 
                                # the result being *one* file.
git clone aBundle newRepo       # recreate a full repo
# check if the cloned repo contains only packaged object

If this works, you might go on, using the new cloned repo as your main repo.

半世蒼涼 2024-12-25 06:25:41

来自 git-gui 的警告只是暗示您可能需要进行一些维护。对于大多数人来说,拥有大量物体只会减慢他们的速度。对于您的情况,您应该禁用该警告。有问题的函数是 hint_gc ,它是从 git-gui 脚本文件末尾附近调用的。只需将其注释掉,如下所示。

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

多重提交业务是一个标志,决定我们是作为提交工具还是通用应用程序运行。

如果你想在其他地方正常使用 git-gui,那么你可以添加一个存储库特定的标志。像这样的东西:

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

应该让你使用 git config --bool gui.skip_gc_warning true 来在每个存储库的基础上禁用它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文