git:是否可以保存试运行的打包对象并稍后推送它们?
我正在尝试推送一堆包含大量代码和几千个 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 分钟)。
所以我想我的问题可以是这样的:
- 是否可以保存在试运行中创建的打包对象?
- 保存后,是否可以推送那些打包的对象并避免重新打包?
我在 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:
- Is it possible to save the packed objects created in a dry run?
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您运行 git gc ,那么 git 将打包存储库中所有可访问的对象。当您随后推送时,它似乎会重新打包需要推送到远程存储库的对象,但它将能够重新使用本地包文件中的打包对象,并且应该跑得更快。
If you run
git gc
then git will pack all reachable objects in your repository. When you subsequentlypush
, 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.