git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Schuberth <sschuberth@gmail.com>
To: git@vger.kernel.org
Subject: Questions on passing --depth to git-clone vs. git-fetch
Date: Wed, 6 Jan 2016 13:30:19 +0100	[thread overview]
Message-ID: <n6j1cs$p4$1@ger.gmane.org> (raw)

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

             reply	other threads:[~2016-01-06 12:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-06 12:30 Sebastian Schuberth [this message]
2016-01-06 12:41 ` Questions on passing --depth to git-clone vs. git-fetch 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='n6j1cs$p4$1@ger.gmane.org' \
    --to=sschuberth@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).