git clone 的进度指示器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4640020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Progress indicator for git clone
提问by Olivier Lalonde
Is it possible to get a progress bar when doing a git clone
? I'm wondering because I am currently doing a git clone that has taken a few minutes so far and would be curious to know if it is going to finish soon.
执行时是否可以获得进度条git clone
?我想知道,因为我目前正在做一个 git clone,到目前为止已经花了几分钟,并且很想知道它是否会很快完成。
采纳答案by araqnid
Not really. There are various stages to git clone
:
并不真地。有不同的阶段git clone
:
- discover the objects that need to be sent ("Counting objects: nnn")
- compress and send those objects
- index the received pack
- check out received files
- 发现需要发送的对象(“计数对象:nnn”)
- 压缩并发送这些对象
- 索引收到的包
- 查看收到的文件
Stage 1 involves walking through the commit graph from each branch head finding all the commits and associated objects: since there is no idea beforehand of how many commits there are, the progress of this can't be gauged. Sadly this is often where a lot of the time in a clone operation is taken up.
阶段 1 涉及从每个分支头遍历提交图,找到所有提交和相关对象:由于事先不知道有多少提交,因此无法衡量其进度。遗憾的是,这通常会占用克隆操作的大量时间。
Stage 2 does have a progress counter, although it counts objects rather than volume (so its rate varies, especially if the repo has large blobs)
第 2 阶段确实有一个进度计数器,尽管它计算的是对象而不是体积(所以它的速率会有所不同,特别是如果 repo 有大 blob)
Stages 3 and 4 have progress counters, although they are usually much faster than the previous two stages.
第 3 和第 4 阶段有进度计数器,尽管它们通常比前两个阶段快得多。
回答by Sasha Pachev
You can do:
你可以做:
du -s .git
to monitor changes in the size of temporary content to get an idea.
监视临时内容大小的变化以获得一个想法。
watch du -s .git
allows you to monitor without having to retype the command. Something like the one-liner below will give periodically you the data accumulation rate in kB per second:
允许您进行监控而无需重新键入命令。类似于下面的单行代码会定期为您提供每秒 kB 的数据累积率:
delay=5; prev=`du -sk .git/ | cut -f 1`; sleep $delay; while true; do cur=`du -sk .git/ | cut -f 1`; expr \( $cur - $prev \) / $delay ; prev=$cur; sleep $delay; done
回答by VonC
I am currently doing a git clone that has taken a few minutes so far and would be curious to know if it is going to finish soon.
我目前正在做一个 git clone,到目前为止已经花了几分钟,很想知道它是否会很快完成。
With Git 2.10 (Q3 2016), git clone --progress
will be more verbose.
使用 Git 2.10(2016 年第三季度),git clone --progress
将更加冗长。
See commit 38e590eby Jeff King (peff
)
(Merged by Junio C Hamano in commit a58a8e3Aug. 4th 2016)
请参阅Jeff King ( ) 的commit 38e590e (由 Junio C Hamano在2016 年 8 月 4 日的commit a58a8e3 中合并)peff
clone
: use a real progress meter for connectivity checkBecause the initial connectivity check for a cloned repository can be slow, 0781aa4 (
clone
: let the user know whencheck_everything_connected
is run, 2013-05-03)added a "fake" progress meter; we simply say "Checking connectivity
" when it starts, and "done
" at the end, with nothing between.Since
check_connected()
now knows how to do a real progress meter, we can drop our fake one and use that one instead.
clone
:使用真正的进度表进行连接检查因为克隆存储库的初始连接检查可能很慢,0781aa4(
clone
:让用户知道何时check_everything_connected
运行,2013-05-03)添加了一个“假”进度表;我们只是Checking connectivity
在开始时说“ ”,done
在结束时说“ ” ,中间没有任何内容。既然
check_connected()
现在知道如何做一个真正的进度表,我们可以放弃我们的假的并使用那个代替。
As noted by ks1322in the comments
--progress
is enabled by default when you rungit clone
from a terminal. There is no need to write it explicitly for terminal.
--progress
git clone
从终端运行时默认启用。无需为终端显式编写它。
回答by Jonas Gr?ger
You might want to take a look at the folder
你可能想看看文件夹
$project/.git/objects/pack
While cloning, there should be a file starting with tmp_pack_
. It contains the currently downloading git pack.
克隆时,应该有一个以tmp_pack_
. 它包含当前下载的 git 包。
With this information you might be able to eyeball the duration.
有了这些信息,您就可以观察持续时间。
回答by mkt
How about git clone --progress
?
怎么样git clone --progress
?