可以“git fetch”吗?被告知不要使用“git upload-pack”对于本地存储库?

发布于 2024-09-11 05:40:48 字数 718 浏览 2 评论 0原文

当使用 git fetch 来将引用从一个(非常大的)存储库获取到本地计算机上的另一个存储库时,git upload-pack 需要很长时间才能创建包文件。在本地情况下,不需要最大限度地减少传输的数据量,并且我不关心因丢失增量压缩而损失的磁盘空间,因此理想情况下,我更喜欢复制丢失的对象而不是打包然后进口的。有没有办法告诉 git fetch 在使用本地传输时只复制丢失的对象?

或者,更一般地说,有没有办法在全局范围内抑制包文件的生成?实际上,我只是想使用 git 作为版本控制的文件系统,它不会为相同的文件占用额外的空间 - 打包和重新打包似乎是一个耗时的步骤,这使得这很尴尬。

顺便说一句,我花了一些时间尝试优化配置选项,以便重新打包不会花费那么长时间(也不会开始颠簸),所以我不认为答案是“使用这些配置选项,打包会发生得更快” - 但是,也许我都错了,所以为了清楚起见,我通常使用的配置选项(在具有 2 GiB RAM 的机器上)是:

core.deltacachesize=1
core.packedgitwindowsize=16m
core.packedgitlimit=128m
pack.packsizelimit=512m
pack.windowmemory=200m
pack.deltacachesize=200m
pack.window=4
pack.compression=3
pack.threads=0
gc.auto=0
gc.pruneexpire=never
receive.autogc=false

When using git fetch to fetch refs from one (very large) repository to another one on the local machine, git upload-pack takes a very long time to create pack files. In the local case there's not such a need to minimize the amount of data transported, and I don't care about disk space lost by losing delta compression, so ideally I'd prefer for the missing objects to be copied rather than packed and then imported. Is there any way to tell git fetch to just copy the missing objects when using the local transport?

Or, more generally, is there a way to suppress the generation of pack files globally? Really I just want to use git as a versioned filesystem that doesn't use up extra space for identical files - packing and repacking seems to be the time-consuming step that makes this awkward.

Incidentally, I've spent some time trying to optimize config options so that repacking doesn't take so long (nor start thrashing) so I don't think the answer is "use these config options and packing will happen much faster" - however, perhaps I've got that all wrong, so just to be clear, the config options that I'm typically using (on a maching with 2 GiB of RAM) are:

core.deltacachesize=1
core.packedgitwindowsize=16m
core.packedgitlimit=128m
pack.packsizelimit=512m
pack.windowmemory=200m
pack.deltacachesize=200m
pack.window=4
pack.compression=3
pack.threads=0
gc.auto=0
gc.pruneexpire=never
receive.autogc=false

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

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

发布评论

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

评论(3

帅冕 2024-09-18 05:40:48

也许您可以使用替代替代对象存储)机制;这将允许与其他本地存储库共享对象数据库,然后不必打包它们。

要进行设置,请使用 'git clone'存储库,但是当您本地有类似的存储库时,或者只是编辑 .git/objects/info/alternates 文件

Perhaps you could use alternates (alternate object storage) mechanism; this would allow sharing object database with other local repository, and then not having to pack them.

To set up this, use 'git clone' using either --shared option if cloning from local repository, or --reference <repository> if cloning from remote repository but when you have similar repository locally, or just edit .git/objects/info/alternates file.

那片花海 2024-09-18 05:40:48

我有一个普通的旧 git clone 不会克隆的存储库:

$ git clone $url
Cloning into foo...
remote: Counting objects: 6142, done.
error: pack-objects died of signal 9839/6058)   
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed

虽然它被它覆盖的进度文本隐藏,但失败的错误消息是 error: pack-objects dead of signal 9代码>.

我可以通过在客户端禁用打包来防止该错误。我通过发出一系列命令(与 git 1.7.4.1 一起发出)来完成此操作,这些命令基本上执行 git clone 的操作,但使用一个额外的命令将 pack.depth 设置为0 在运行 git fetch 之前。

mkdir foo
cd foo
git init
git remote add origin $url
git config pack.depth 0
git fetch origin
git branch --set-upstream origin origin/master
git checkout master

I have a repository that plain old git clone will not clone:

$ git clone $url
Cloning into foo...
remote: Counting objects: 6142, done.
error: pack-objects died of signal 9839/6058)   
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed

Although it's concealed by the progress text which it overwrite, the failing error message is error: pack-objects died of signal 9.

I was able to prevent the error by disabling packing on the client side. I did this by issuing a sequence of commands (issued with git 1.7.4.1) that basically do what git clone does, but with an extra command to set pack.depth to 0 before running git fetch.

mkdir foo
cd foo
git init
git remote add origin $url
git config pack.depth 0
git fetch origin
git branch --set-upstream origin origin/master
git checkout master
红玫瑰 2024-09-18 05:40:48

也许(未经测试)设置 http-backend 用于您的第一个存储库(您从中获取的存储库)。

这种服务器有一个您可能感兴趣的设置:

http.uploadpack

这为 git fetch-packgit ls-remote 客户端提供服务。
默认情况下它是启用的,但是存储库可以通过将此配置项设置为 false 来禁用它。

Maybe (not tested) setting up a http-backend for your first repo (the one from which you are fetching).

This kind of server has a setting which could be of interest in your case:

http.uploadpack

This serves git fetch-pack and git ls-remote clients.
It is enabled by default, but a repository can disable it by setting this configuration item to false.

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