预测在git推送中将推送多少数据 [英] Predict how much data will be pushed in a git push

查看:130
本文介绍了预测在git推送中将推送多少数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我偶尔会遇到一个昂贵的互联网连接,我想知道(至少大概)多少数据将被推送到远程的 git push

解决方案

实际上,我认为我喜欢我的评论足以将其作为答案张贴!



当您推送时,git将创建一个所有必需​​对象的包并将其上传到远程。这意味着我们正在寻找预测包装大小的方法。由于包被压缩,这使得很难根据差异或对象大小做任何事情;我们真正想要做的只是看看这个包装会有多大。如果你能在打包后立即中断推送,并根据包的大小决定继续推进,那就太好了,但我认为这是不可能的。我最好的猜测是尝试重新创建将被推送并检查的包。

包文件基本上是一个包含头信息的包(看看来源 if you喜欢)。这意味着这是一个方便的瓷器命令,将创建一个您关心的大小的文件。 (比尝试使用包装对象< )使用类似这样的方式:

  git bundle create foo.bundle ^ origin / master master 

这会给你一个包含所有需要的东西的包,因为遥控器有起始/主 - 同样的事情应该由 git push origin master 推送。如果你有更多的分支你会推动,你可以把它们固定下来;它只是采取rev-list参数:

  git bundle create foo.bundle ^ origin / master master ^ origin / topic topic .. 。

只需检查创建的捆绑包的大小;它应该几乎等于你最终推动的东西。这确实意味着你最终必须两次创建包(一次使用捆绑包并且一次使用一次),但除非这是一个需要很长时间收拾的非常大的推动,否则它不应该是一个巨大的问题。


I am occasionally on an expensive Internet connection and I would like to know (at least approximately) how much data will be pushed to the remote in a git push.

解决方案

Actually, I think I like my comment enough to post it as an answer!

When you push, git creates a pack of all the necessary objects and uploads that to the remote. This means we're looking for a way to predict that pack size. Since the packs are compressed, that makes it very difficult to do anything based on diffs or object sizes; what we really want to do is just see how big that pack will be. It'd be nice if you could interrupt the push, just after it's constructed the pack, and decide to proceed based on the pack size, but I don't think that's possible. My best guess is to try to recreate the pack that would be pushed and inspect that.

A bundle file is basically a pack with header information (have a look at the source if you like). This means it's a convenient porcelain command that'll create a file with the size you care about. (Much easier than trying to use pack-objects manually.) Use something like this:

git bundle create foo.bundle ^origin/master master

That'll give you a bundle containing everything needed to get to master, given that the remote has origin/master - exactly the same thing that should be pushed by git push origin master. If you have additional branches you'll be pushing, you can tack them on as well; it's just taking rev-list args:

git bundle create foo.bundle ^origin/master master ^origin/topic topic ...

Just check the size of that created bundle; it should be nearly equivalent to what you'll end up pushing. This does mean that you'll end up having to create the pack twice (once with the bundle and once with the push), but unless this is a really big push which takes a long time to pack up, that shouldn't be a huge problem.

这篇关于预测在git推送中将推送多少数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆