git:是否可以保存试运行的打包对象并稍后推送它们?

发布于 2024-09-05 13:30:24 字数 2581 浏览 5 评论 0原文

我正在尝试推送一堆包含大量代码和几千个 MP3 和 PDF 文件的提交(每个文件大小从 5-40 MB 不等)。

Git 成功打包了对象:

C:\MyProject> git push
Counting objects: 7582, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7510/7510), done.

但由于某些尚不清楚的原因,它无法发送推送。

问题是重新打包文件需要很长时间(我使用的是电池供电的笔记本电脑,打包大约需要 20 分钟)。

所以我想我的问题可以是这样的:

  1. 是否可以保存在试运行中创建的打包对象?
  2. 保存后,是否可以推送那些打包的对象并避免重新打包?

我在 git 手册和其他地方查找了它,但找不到任何结论性的东西。

任何帮助或指示表示赞赏。


编辑 - 添加了错误消息:

我第一次从命令行运行此命令(`git push')时收到此错误:

fatal: sha1 file '<stdout>' write error: Invalid argument
error: pack-objects died with strange error
error: failed to push some refs to 'account@server:project.git'

第二次(git push origin master -v) 我收到此错误:

Pushing to account@server:project.git
Counting objects: 7582, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7510/7510), done.
fatal: sha1 file '<stdout>' write error: Invalid argument
error: pack-objects died with strange error
error: failed to push some refs to 'account@server:project.git'

请注意,在这两种情况下,压缩完成后,我收到此对话框:

---------------------------
PuTTY Fatal Error
---------------------------
Network error: Software caused connection abort
---------------------------
OK   
---------------------------

对话框打开时,控制台显示如下(单击“确定”后,“写入对象”行被删除):

Pushing to account@server:project.git
Counting objects: 7582, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7510/7510), done.
Writing objects:   0% (1/7525)

编辑2 - 按照 Charles Bailey 的建议运行 git gc 后,大约 1.5 小时后我得到了以下输出:

C:\Projects\MyProject>git gc
Counting objects: 10926, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (10125/10125), done.
warning: failed utime() on c:/Projects/MyProject/.git/objects/.tmp-10596-pack-a3a5ef775308593167a669b19aa752d2f484f768.pack: Permission denied
warning: failed utime() on c:/Projects/MyProject/.git/objects/.tmp-10596-pack-380270a0b5f3c7d30731c8e19f9271a59ea05e3d.pack: Permission denied
Writing objects: 100% (10926/10926), done.
Total 10926 (delta 719), reused 10858 (delta 719)
mv: cannot move `/c/Projects/MyProject/.git/objects/pack/pack-5dc233ff7aa1c33fc4845251186d5bafcefe3a11.pack' to `/c/Projects/MyProject/.git/objects/pack/old-pack-5dc233ff7aa1c33fc4845251186d5bafcefe3a11.pack'
error: failed to run repack

I'm trying to push a bunch of commits that contain a lot of code and a few thousand MP3 and PDF files besides (ranging from 5-40 MB each).

Git successfully packs the objects:

C:\MyProject> git push
Counting objects: 7582, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7510/7510), done.

But it fails to send the push for some as yet unknown reason.

The problem is that it takes it a very long time to repack the files (I'm on a battery-powered laptop and it took about 20 minutes to pack).

So I guess my question can be phrases thus:

  1. Is it possible to save the packed objects created in a dry run?
  2. Once saved, is it possible to push those packed objects and avoid repacking?

I looked it up in the git manual and elsewhere and couldn't find anything conclusive.

Any help or pointers are appreciated.


EDIT - Added the error messages:

The first time I ran this from the commandline (`git push') I got this error:

fatal: sha1 file '<stdout>' write error: Invalid argument
error: pack-objects died with strange error
error: failed to push some refs to 'account@server:project.git'

The second time (git push origin master -v) I got this error:

Pushing to account@server:project.git
Counting objects: 7582, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7510/7510), done.
fatal: sha1 file '<stdout>' write error: Invalid argument
error: pack-objects died with strange error
error: failed to push some refs to 'account@server:project.git'

Note that in both cases, after the compression finished, I got this dialog:

---------------------------
PuTTY Fatal Error
---------------------------
Network error: Software caused connection abort
---------------------------
OK   
---------------------------

While the dialog was open, the console read as follows (the "Writing objects" line was erased after clicking OK):

Pushing to account@server:project.git
Counting objects: 7582, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7510/7510), done.
Writing objects:   0% (1/7525)

EDIT 2 - After running git gc per Charles Bailey's suggestion, I got the following output after about 1.5 hours:

C:\Projects\MyProject>git gc
Counting objects: 10926, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (10125/10125), done.
warning: failed utime() on c:/Projects/MyProject/.git/objects/.tmp-10596-pack-a3a5ef775308593167a669b19aa752d2f484f768.pack: Permission denied
warning: failed utime() on c:/Projects/MyProject/.git/objects/.tmp-10596-pack-380270a0b5f3c7d30731c8e19f9271a59ea05e3d.pack: Permission denied
Writing objects: 100% (10926/10926), done.
Total 10926 (delta 719), reused 10858 (delta 719)
mv: cannot move `/c/Projects/MyProject/.git/objects/pack/pack-5dc233ff7aa1c33fc4845251186d5bafcefe3a11.pack' to `/c/Projects/MyProject/.git/objects/pack/old-pack-5dc233ff7aa1c33fc4845251186d5bafcefe3a11.pack'
error: failed to run repack

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

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

发布评论

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

评论(1

聊慰 2024-09-12 13:30:24

如果您运行 git gc ,那么 git 将打包存储库中所有可访问的对象。当您随后推送时,它似乎会重新打包需要推送到远程存储库的对象,但它将能够重新使用本地包文件中的打包对象,并且应该跑得更快。

If you run git gc then git will pack all reachable objects in your repository. When you subsequently push, it will appear to repack the objects that it needs to push to the remote repository but it will be able to re-use the packed for that are in your local pack file and it should run a lot faster.

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