After using "git clone" with the "--single-branch"
option, the configured refspec for this repo was
After fetching changes from this repo again, it'll
receive all refs instead of the single ref which
was used in "--single-branch". Fixing the refspec
that it just contains the ref of the branch which
was cloned.

Signed-off-by: Ralf Thielow <>
 builtin/clone.c | 5 ++++-
 1 Datei geändert, 4 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 5e8f3ba..3e74d55 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -754,7 +754,10 @@ int cmd_clone(int argc, const char **argv, const char 
                strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
-       strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
+       if (option_single_branch)
+               strbuf_addf(&value, "+%s%s:%s%s", src_ref_prefix, 
option_branch, branch_top.buf, option_branch);
+       else
+               strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
        if (option_mirror || !option_bare) {
                /* Configure the remote */

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