33

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.

Yi Jiang
  • 49,435
  • 16
  • 136
  • 136
Olivier Lalonde
  • 19,423
  • 28
  • 76
  • 91
  • 1
    Git 2.10 should be more talkative with `git clone --progress`: see [my answer below](http://stackoverflow.com/a/38783446/6309) – VonC Aug 05 '16 at 07:22

6 Answers6

24

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.

araqnid
  • 127,052
  • 24
  • 157
  • 134
16

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
thecoshman
  • 8,394
  • 8
  • 55
  • 77
Sasha Pachev
  • 5,162
  • 3
  • 20
  • 20
15

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.

As noted by ks1322 in the comments

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

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @CiroSantilli新疆改造中心六四事件法轮功 But the --progress is there, isn't it? (https://git-scm.com/docs/git-clone#git-clone---progress) Even though, yes, it is not in the synopsis. – VonC Sep 14 '18 at 07:59
  • 1
    `--progress` is enabled by default when you run `git clone` from a terminal. There is no need to write it explicitly for terminal. – ks1322 Apr 18 '20 at 09:44
  • @ks1322 Good point, thank you. I have inclduded your comment in the answer for more visibility. – VonC Apr 18 '20 at 15:56
2

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.

Jonas Gröger
  • 1,558
  • 2
  • 21
  • 35
1

How about git clone --progress ?

mkt
  • 29
  • 1
0

This may not be the direct answer to the question precisely. In my case, when I'm trying to get the progress of git-lfs clone a large-language-model, which might take quite a while, I just get into the cloning directory and do watch du -ksh if you're on Linux

j3ffyang
  • 1,049
  • 12
  • 12