git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 7, 2025, 22:15 UTC
Message-ID
<xmqqa522icjy.fsf@gitster.g>
In-Reply-To
<BL3PR13MB5209A87037FC19CBB9B2916EBBE0A@BL3PR13MB5209.namprd13.prod.outlook.com>
Andrew Harmon <aharmon@signalquest.com> writes:
Show 18 quoted lines
> # 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 ...

Show 7 quoted lines
> ## 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").
Previous: Andrew HarmonNext: Andrew Harmon
Message 2 of 7 in “[BUG] git clone from bundle with --all does not fetch all refs”
  1. Andrew HarmonOct 7, 2025
  2. Junio C HamanoOct 7, 2025
  3. Andrew HarmonOct 7, 2025
  4. Junio C HamanoOct 8, 2025
  5. Andrew HarmonOct 8, 2025
  6. Andreas SchwabOct 8, 2025
  7. Andrew HarmonOct 8, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.