使用 Git 强制远程存储库压缩 (GC)
我正在使用 Git 来对一系列二进制文件进行版本控制。它们压缩得很好,但是当我推送它们时,我的中央存储库似乎没有压缩。它们占用了我相当多的配额,所以我想看看是否有办法强制远程存储库执行 GC。
这可能吗?我正在开发 Project Locker,所以我不相信我有 SSH 访问权限来进入并 GC 存储库我。有什么想法吗?谢谢。
I'm using Git to version a series of binary files. They compress pretty well, but my central repos do not seem to be compressing when I push to them. They're eating up a decent amount of my quota, so I was looking to see if there was a way to force the remote repo to do a GC.
Is this possible? I'm working on Project Locker so I don't believe I have SSH access to go in and GC the repo myself. Any ideas? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您自己无法运行 git gc,则必须欺骗它自动运行。那时您将无法完全控制它,但您至少应该能够让它运行。
git gc --auto
由多个命令运行;这里相关的是 receive-pack,它在远程运行以接收包作为推送的一部分。gc --auto
仅当有足够的松散对象时才重新打包;截止值由配置参数gc.auto
确定,默认为 6700。如果您有权访问远程的 gitconfig,则可以将该截止值暂时设置为 1。存储库中肯定至少有 1 个松散对象,因此这应该会导致 gc --auto 在您下次推送时执行其操作。
如果你无法访问远程的 gitconfig,我能想到的就是人为地创建一堆松散的对象。您可以通过创建一个分支,向其提交一堆小文件(具有不同内容),将分支推送到远程,然后从远程删除分支来做到这一点。 (重要的是要改变内容,否则他们只会使用相同的斑点。)冲洗并重复。
If you can't run
git gc
yourself, you're going to have to trick it into running automatically. You won't have quite such full control over it then, but you should at least be able to get it to run.git gc --auto
is run by several commands; the relevant one here is receive-pack, which is run on the remote to receive a pack as part of a push.gc --auto
only repacks when there are enough loose objects; the cutoff is determined by the config parametergc.auto
, and defaults to 6700.If you have access to the remote's gitconfig, you could set that cutoff to 1 temporarily. There should pretty definitely be at least 1 loose object in the repo, so that should cause
gc --auto
to do its thing the next time you push.If you don't have access to the remote's gitconfig, all I can think to do is artificially create a bunch of loose objects. You could do that by creating a branch, committing a bunch of tiny files (with different content) to it, pushing the branch to the remote, then deleting the branch from the remote. (Important to vary the content, or they'll just use the same blobs.) Rinse and repeat.
这确实是他们需要解决的问题。他们可以使用 post-receive hook 或 cron job 或类似的东西来完成此操作,但如果他们应该维护您的存储库,那么出于多种原因,这也是其中的一部分。
That's really a problem that they need to solve on their end. They can do it with a post-receive hook or a cron job or something similar, but if they're supposed to be maintaining your repositories, that's kind of part of it for numerous reasons.
表单
git-gc
man页面:更进一步:
最后:
Form
git-gc
man page:And further:
And in the end: