Skip to contentSkip to conversation

Does cloning a shallow repo require special setting in the cloned one?

DISCUSSION roylee17 5 participants 8 messages Jun 15, 2016

lore
Share & tools
lore

roylee17

author
#0 lore raw

Hi,

I have a question about cloning shallow repo.

$ git clone --depth 1 git://git2.kernel.org/pub/scm/git/git.git git-shallow
ok, 'git log' gives a 2-revision history.
$ git clone git://git2.kernel.org/pub/scm/git/git.git git-full
'git log' gives a full history
$ git clone --depth 1 git-full git-shallow2
'git log' still gives a full history

Why can't I clone a shallow repo from the git-full? Does it requires some settings in the git-full repo?

Regards,
Roy
Roy

Signature · 2 lines
View this message in context: http://n2.nabble.com/Does-cloning-a-shallow-repo-require-special-setting-in-the-cloned-one--tp2387799p2387799.html
Sent from the git mailing list archive at Nabble.com.
#1 lore raw
Quoted 5 lines · On 2009-02-25 19:49 (-0800), roylee17 wrote:
$ git clone --depth 1 git-full git-shallow2
'git log' still gives a full history

Why can't I clone a shallow repo from the git-full? Does it requires some settings in the git-full repo?

I don't know the "why" part but using file:// URL should work:

    git clone --depth 1 file:///path/to/git-full git-shallow2
#2 lore raw
Quoted 11 lines · Teemu Likonen
Quoted 5 lines · On 2009-02-25 19:49 (-0800), roylee17 wrote:
$ git clone --depth 1 git-full git-shallow2
'git log' still gives a full history

Why can't I clone a shallow repo from the git-full? Does it requires some settings in the git-full repo?

I don't know the "why" part but using file:// URL should work:

    git clone --depth 1 file:///path/to/git-full git-shallow2

I don't think the behavior is intentional, but a side effect of the fact that git takes some shortcuts when cloning locally. In particular, it will try to copy or hardlink the object database rather than transmitting over the git protocol locally. Using file:// has always been the way to suppress that shortcut.

Perhaps to avoid surprise, that optimization should be turned off for options which cause it to behave differently (like --depth). But I have to wonder what the point of --depth is locally; if you are worried about space, hardlinks (the default) or alternates ("clone -s") are a better solution.

-Peff

author
#3 lore raw
Quoted 20 lines · Jeff King
Quoted 11 lines · Teemu Likonen
Quoted 5 lines · On 2009-02-25 19:49 (-0800), roylee17 wrote:
$ git clone --depth 1 git-full git-shallow2
'git log' still gives a full history

Why can't I clone a shallow repo from the git-full? Does it requires some settings in the git-full repo?

I don't know the "why" part but using file:// URL should work:

    git clone --depth 1 file:///path/to/git-full git-shallow2

I don't think the behavior is intentional, but a side effect of the fact that git takes some shortcuts when cloning locally. In particular, it will try to copy or hardlink the object database rather than transmitting over the git protocol locally. Using file:// has always been the way to suppress that shortcut.

Quoted 8 lines

Perhaps to avoid surprise, that optimization should be turned off for options which cause it to behave differently (like --depth). But I have to wonder what the point of --depth is locally; if you are worried about space, hardlinks (the default) or alternates ("clone -s") are a better solution.

-Peff

Actully, the original intention was to find a quick way to checkout and build several projects regularly. The first thing came to me was cloning shallow repos for saving some time. So I tried it with my local repo first.

Later, one of my co-works suggested me to try git archive, and that did reallly fit my needs.

Thanks for clarifying my confusion.

Roy

#4 lore raw
Quoted 26 lines · Roy Lee
Quoted 19 lines · Jeff King
Quoted 11 lines · Teemu Likonen
Quoted 5 lines · On 2009-02-25 19:49 (-0800), roylee17 wrote:
$ git clone --depth 1 git-full git-shallow2
'git log' still gives a full history

Why can't I clone a shallow repo from the git-full? Does it requires some settings in the git-full repo?

I don't know the "why" part but using file:// URL should work:

    git clone --depth 1 file:///path/to/git-full git-shallow2

I don't think the behavior is intentional, but a side effect of the fact that git takes some shortcuts when cloning locally. In particular, it will try to copy or hardlink the object database rather than transmitting over the git protocol locally. Using file:// has always been the way to suppress that shortcut.

Quoted 5 lines

Perhaps to avoid surprise, that optimization should be turned off for options which cause it to behave differently (like --depth). But I have to wonder what the point of --depth is locally; if you are worried about space, hardlinks (the default) or alternates ("clone -s") are a better solution.

Quoted 6 lines

Actully, the original intention was to find a quick way to checkout and build several projects regularly. The first thing came to me was cloning shallow repos for saving some time. So I tried it with my local repo first.

Later, one of my co-works suggested me to try git archive, and that did reallly fit my needs.

Perhaps you would be interested then in contrib/workdir/git-new-workdir script then, which allows for multiple checked out copies from a single repository? Be aware that if you work in those copies, and are not careful, it can lead to confusion; but if all but one of checkouts are read only it could be the best solution.

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#5 lore raw
In reply to Jeff King

Hi,

Quoted 20 lines · Jeff King
Quoted 11 lines · Teemu Likonen
Quoted 5 lines · On 2009-02-25 19:49 (-0800), roylee17 wrote:
$ git clone --depth 1 git-full git-shallow2
'git log' still gives a full history

Why can't I clone a shallow repo from the git-full? Does it requires some settings in the git-full repo?

I don't know the "why" part but using file:// URL should work:

    git clone --depth 1 file:///path/to/git-full git-shallow2

I don't think the behavior is intentional, but a side effect of the fact that git takes some shortcuts when cloning locally. In particular, it will try to copy or hardlink the object database rather than transmitting over the git protocol locally. Using file:// has always been the way to suppress that shortcut.

Quoted 5 lines

Perhaps to avoid surprise, that optimization should be turned off for options which cause it to behave differently (like --depth). But I have to wonder what the point of --depth is locally; if you are worried about space, hardlinks (the default) or alternates ("clone -s") are a better solution.

I think it is way better to warn, since "--depth" is usually passed out of concerns about disk space. And --shared should shut that concern up rather nicely.

builtin-clone.c +4 -1
index c338910..5831034 100644
@@ -511,8 +511,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	refspec.src = src_ref_prefix;
 	refspec.dst = branch_top.buf;
 
-	if (path && !is_bundle)
+	if (path && !is_bundle) {
+		if (option_depth)
+			warning("Ignoring --depth for local clone");
 		refs = clone_local(path, git_dir);
+	}
 	else {
 		struct remote *remote = remote_get(argv[0]);
 		transport = transport_get(remote, remote->url[0]);

Lacks tests,
Dscho

#6 lore raw
Quoted 11 lines · Johannes Schindelin

I think it is way better to warn, since "--depth" is usually passed out of concerns about disk space. And --shared should shut that concern up rather nicely.

builtin-clone.c +0 -0
index c338910..5831034 100644
@@ -511,8 +511,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	refspec.src = src_ref_prefix;
 	refspec.dst = branch_top.buf;

builtin-clone.c int cmd_clone(int argc, const char **argv, const char *prefix) · line 521

Quoted 10 lines
builtin-clone.c +4 -1
 
-	if (path && !is_bundle)
+	if (path && !is_bundle) {
+		if (option_depth)
+			warning("Ignoring --depth for local clone");
 		refs = clone_local(path, git_dir);
+	}
 	else {
 		struct remote *remote = remote_get(argv[0]);
 		transport = transport_get(remote, remote->url[0]);

That seems reasonable to me.

-Peff

author
#7 lore raw
In reply to Teemu Likonen
Quoted 5 lines · Teemu Likonen
Quoted 3 lines · On 2009-02-25 19:49 (-0800), roylee17 wrote:
$ git clone --depth 1 git-full git-shallow2
'git log' still gives a full history
Quoted 7 lines
Quoted 2 lines

Why can't I clone a shallow repo from the git-full? Does it requires some settings in the git-full repo?

I don't know the "why" part but using file:// URL should work:

   git clone --depth 1 file:///path/to/git-full git-shallow2

Thanks, Teemu. file:///path/to/git-full works.