Jeff King <peff <at>> writes:
> [..]
> Secondly, I do get the same warning about HEAD:
>   $ git clone repo.bundle repofrombundle
>   Cloning into 'repofrombundle'...
>   Receiving objects: 100% (3/3), done.
>   warning: remote HEAD refers to nonexistent ref, unable to checkout.
> but that warning makes sense. You did not create a bundle that contains
> HEAD, therefore when we clone it, we do not know what to point HEAD to.
> You probably wanted "git bundle create ../repo.bundle --all" which
> includes both "master" and "HEAD".

I'd like to revive this discussion and submit a patch, as I just spent
significant time wondering why git clone failed. It's been a while, so I'll
summarize: when you make a git bundle without including HEAD explicitly,
then clone from that bundle, Git throws a warning and leaves you with a
broken HEAD.

I do not agree that the warning makes sense. It implies that HEAD exists but
is invalid. In reality, no ref is referred to by HEAD in the first place.
Furthermore, .git/HEAD in the clone is "autocorrected" to be
refs/heads/master, so the error message is even more misleading.

It's like saying "Our CEO's guitar is actually an air guitar", then
explaining where he stores his guitar, when I don't work in a company in the
first place.

> It would be slightly more accurate to say "the remote HEAD does not
> exist", rather than "refers to nonexistent ref".  It would perhaps be
> nicer still for "git clone" to make a guess about the correct HEAD when
> one is not present (especially in the single-branch case, it is easy to
> make the right guess).

Seems sensible at first sight, though it seems orthogonal to the warning

> Patches welcome. In the meantime, you can clone with "-b master" to tell
> it explicitly, or you can "git checkout master" inside the newly-cloned
> repository.

Alright :) See below.

Cheers, Bram

>From bc799b12b659d7ab20df7fe420d5f1f1c90450aa Mon Sep 17 00:00:00 2001
From: Bram Geron <>
Date: Wed, 28 May 2014 15:54:37 +0100
Subject: [PATCH] Clearer error message when cloning a bundle without a HEAD

 builtin/clone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 9b3c04d..e3c1447 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -623,7 +623,7 @@ static int checkout(void)
        head = resolve_refdup("HEAD", sha1, 1, NULL);
        if (!head) {
-               warning(_("remote HEAD refers to nonexistent ref, "
+               warning(_("no HEAD in remote or HEAD refers to nonexistent ref, 
                          "unable to checkout.\n"));
                return 0;

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to