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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:55:16  来源:igfitidea点击:

Progress indicator for git clone

gitprogressgit-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

  1. discover the objects that need to be sent ("Counting objects: nnn")
  2. compress and send those objects
  3. index the received pack
  4. check out received files
  1. 发现需要发送的对象(“计数对象:nnn”)
  2. 压缩并发送这些对象
  3. 索引收到的包
  4. 查看收到的文件

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 --progresswill 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 Hamano2016 年 8 月 4 日的commit a58a8e3 中合并peff

clone: use a real progress meter for connectivity check

Because the initial connectivity check for a cloned repository can be slow, 0781aa4 (clone: let the user know when check_everything_connectedis 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

正如ks1322评论中所指出的

--progressis enabled by default when you run git clonefrom a terminal. There is no need to write it explicitly for terminal.

--progressgit 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