From: Junio C Hamano <gitster@pobox.com>
To: Andrew Harmon <aharmon@signalquest.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [BUG] git clone from bundle with --all does not fetch all refs
Date: Tue, 07 Oct 2025 15:15:13 -0700 [thread overview]
Message-ID: <xmqqa522icjy.fsf@gitster.g> (raw)
In-Reply-To: <BL3PR13MB5209A87037FC19CBB9B2916EBBE0A@BL3PR13MB5209.namprd13.prod.outlook.com> (Andrew Harmon's message of "Tue, 7 Oct 2025 21:11:43 +0000")
Andrew Harmon <aharmon@signalquest.com> writes:
> # Problem with git bundle --all and git clone for air-gapped
> transfer to offline environments
>
> ## Description
>
> When creating a bundle using `git bundle create --all`, all refs
> including `refs/remotes/origin/*` are included in the
> bundle. However, when cloning from this bundle using `git clone`,
> these remote refs are not automatically fetched, making many
> branches inaccessible.
>
> ## Steps to Reproduce
>
> 1. In a repository with multiple branches and remote tracking branches (e.g., after cloning from GitLab/GitHub)
> 2. Create a bundle: `git bundle create repo.bundle --all`
> 3. Verify bundle contents: `git bundle list-heads repo.bundle` (shows both `refs/heads/*` and `refs/remotes/origin/*`)
> 4. Clone from bundle: `git clone repo.bundle cloned-repo`
> 5. Check available branches: `cd cloned-repo && git branch -a`
> ## Expected Behavior
>
> All refs included in the bundle (both `refs/heads/*` and `refs/remotes/origin/*`) should be accessible after cloning. Users should be able to see and checkout all branches that were in the original repository.
If I am not misreading the scenario presented, then this expectation
is wrong.
> ## Actual Behavior
>
> Only refs under `refs/heads/*` in the bundle become remote tracking branches. Refs stored as `refs/remotes/origin/*` in the bundle are not fetched during clone, making these branches inaccessible without manual intervention.
This is totally expected. Think of cloning from a bundle is just
like cloning from the original remote (limited to the refs included
in the bundle, of course). Local branches of the remote (i.e. the
ones that corresponds to refs/heads/* you saw in your bundle) become
your remote-tracking branches. Their remote-tracking branches are
not even visible, unless you explicitly ask "clone" to. Which means ...
> ## Workaround
>
> After cloning, manually fetch the remote refs:
>
> ```bash
> git fetch origin 'refs/remotes/origin/*:refs/remotes/origin/*'
> ```
... this is not even a workaround, but how you would ask for their
remote-tracking branches.
Or
$ git init && git fetch repo.bndl "refs/*:refs/*"
which is like doing a mirror clone ("git clone --mirror").
next prev parent reply other threads:[~2025-10-07 22:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 21:11 [BUG] git clone from bundle with --all does not fetch all refs Andrew Harmon
2025-10-07 22:15 ` Junio C Hamano [this message]
2025-10-07 23:11 ` Andrew Harmon
2025-10-08 17:23 ` Junio C Hamano
2025-10-08 18:17 ` Andrew Harmon
2025-10-08 18:51 ` Andreas Schwab
2025-10-08 19:19 ` Andrew Harmon
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=xmqqa522icjy.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=aharmon@signalquest.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).