Subject: Re: [BUG] git clone from bundle with --all does not fetch all refs

From: Junio C Hamano <[email-masked]>
Date: Tue, 07 Oct 2025 15:15:13 -0700

Andrew Harmon <[email-masked]> 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").