Progress indicator for git clone

旧巷老猫 提交于 2019-12-29 04:33:13

问题


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.


回答1:


Not really. There are various stages to 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

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.

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)

Stages 3 and 4 have progress counters, although they are usually much faster than the previous two stages.




回答2:


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:

    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



回答3:


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.

With Git 2.10 (Q3 2016), git clone --progress will be more verbose.

See commit 38e590e by Jeff King (peff)
(Merged by Junio C Hamano in commit a58a8e3 Aug. 4th 2016)

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_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.




回答4:


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.

With this information you might be able to eyeball the duration.




回答5:


How about git clone --progress ?



来源:https://stackoverflow.com/questions/4640020/progress-indicator-for-git-clone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!