git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Questions on passing --depth to git-clone vs. git-fetch
@ 2016-01-06 12:30 Sebastian Schuberth
  2016-01-06 12:41 ` Duy Nguyen
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Sebastian Schuberth @ 2016-01-06 12:30 UTC (permalink / raw)
  To: git

Hi,

I recently compared the results of doing

    $ git clone --depth=1 https://github.com/git/git.git git-clone-depth-1

versus

    $ mkdir git-fetch-depth-1
    $ cd git-fetch-depth-1
    $ git init
    $ git remote add origin https://github.com/git/git.git
    $ git fetch --depth=1

and noticed a few things:

1. The docs of clone [1] say about --depth "Create a shallow clone with a history truncated to the specified number of revisions" while for fetch the docs [2] say "[...] to the specified number of commits [...]". As in this particular case revision are always commits, I think the clone docs should also say "commits".

2. In the fetch docs --depth is described to "Deepen or shorten the history of a shallow repository created by git clone". That sounds as if my example from above where I initialze a repo manually would not allow fetch to be called with --depth as I did not clone before. But in fact my example works fine. I guess we need some clarfication in the wording here.

3. When running "git log --all -oneline" in the two working trees I get different results, which is not what I'd expect:

    $ cd git-clone-depth-1
    $ git log --all --oneline
      7548842 Git 2.7

versus

    $ cd git-fetch-depth-1
    $ git log --all --oneline
      b819526 Merge branch 'jk/notes-merge-from-anywhere' into pu
      e2281f4 What's cooking (2016/01 #01)
      ef7b32d Sync with 2.7
      7548842 Git 2.7
      833e482 Git 2.6.5

So in the clone case only the specified number of commits from the tip of the default branch (master in this case) is fetched, not of each remote branch history. fetch in the other hand really gets the specified number of commits from the tip of each remote branch history. I don't know whether this behavior is inded or not as I cannot find any docs on it either way. But it seems inconsistent to me that clone with --depth only gets the history for the default branch, as clone without --depth would give me the history of all branches.

For completeness, I'm using Git for Windows 2.7.

Any comments?

[1] https://git-scm.com/docs/git-clone
[1] https://git-scm.com/docs/git-fetch

-- 
Sebastian Schuberth

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-01-13 18:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-06 12:30 Questions on passing --depth to git-clone vs. git-fetch Sebastian Schuberth
2016-01-06 12:41 ` Duy Nguyen
2016-01-06 13:04   ` Sebastian Schuberth
2016-01-06 13:06     ` [PATCH] docs: clarify that passing --depth to git-clone implies --single-branch Sebastian Schuberth
2016-01-07 19:45       ` Junio C Hamano
2016-01-08  9:18 ` [PATCH] docs: say "commits" in the --depth option wording for git-clone Sebastian Schuberth
2016-01-13 18:22   ` Sebastian Schuberth
2016-01-08  9:32 ` [PATCH] docs: clarify that --depth for git-fetch works with newly initialized repos Sebastian Schuberth
2016-01-13 18:24   ` Sebastian Schuberth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).