title: What does depth for git clone mean?
body: <p>We tried to speed up the CI build of one of our software projects at work. Somebody committed some huge (by git's standards) binaries early in the project's life. Rewriting git's history just to get rid of them seems like too much trouble, so we figured doing a shallow clone that avoided those big early commits would be good enough.</p>
  
  <p>I did some experiments with <code>--depth</code> parameter for clone and encountered some weird behavior. This is what help for git clone says about it:</p>
  
  <pre><code>--depth &lt;depth&gt;
             Create a shallow clone with a history truncated to the specified number of commits. Implies
             --single-branch unless --no-single-branch is given to fetch the histories near the tips of all
             branches. If you want to clone submodules shallowly, also pass --shallow-submodules.
  </code></pre>
  
  <p>This would indicate that <code>&lt;depth&gt;</code> will equal the number of commits that will be fetched during the clone, but it's not the case. This is what I got when I tried different values for depth:</p>
  
  <pre><code>| depth   | commit count linux repo | commit count git repo |
  |---------|-------------------------|-----------------------|
  | 1       | 1                       | 1                     |
  | 5       | 15                      | 13                    |
  | 10      | 80                      | 46                    |
  | 100     | 93133                   | 39552                 |
  | 1000    | 788718                  | 53880                 |
  </code></pre>
  
  <p>For cloning I used this command <code>git clone --depth 10 https://github.com/torvalds/linux.git</code>, <code>git clone --depth 100 https://github.com/git/git.git</code>, and for counting the commits I used this <code>git log --oneline | wc -l</code>. (At work I observed the same thing with a GitLab server, so it can't be an artifact of how GitHub works.)</p>
  
  <p>Does anybody know what is going on? How does the value for depth correspond to the actual amount of data downloaded? Do I understand the documentation wrongly, or is there a bug?</p>
  
  <p>EDIT: I added results for a second repo</p>