Re: Questions on passing --depth to git-clone vs. git-fetch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 6, 2016 at 7:30 PM, Sebastian Schuberth
<sschuberth@xxxxxxxxx> wrote:
> 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:

I think the culprit is the "git remote add" line. "git clone --depth"
by default will fetch only one branch (aka --single-branch option in
git-clone). But I suspect when you add a new remote, the default
refspec is to get all refs. So "git fetch --depth=1" means fetch _all_
refs, each one has maximum one commit. "git log --graph --decorate"
should show this clearer.

> 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
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]