1

I have a git repository, and a git bundle file. I can checkout the repository, and apply the bundle on one machine. I would like to use this particular machine as a mirror for this repository, along with the changes from the bundle. However when I try to clone it, the bundle changes don't seem to come across.

This is what I do on machine-A:

git clone [email protected]/repo.git wget https://example.com/extra-upstream.bundle cd repo git fetch ../extra-upstream.bundle '+refs/heads/*:refs/remotes/extra/*' 

This seems to work fine so far - I have the changes I expected.

On machine-B I do the following:

git clone git@machine-A:/repo 

However only the upstream code is cloned, without the branches/remotes from the bundle. What am I missing?

4
  • Machine-B clones all the branches that are present in upstream, no problem there. I'm missing the extra branches from the bundle. Commented Oct 22, 2023 at 19:25
  • 1
    Machine-B clones all the branches that are local in the repo on machine-A. It cannot clone branches that are remote on machine-A. To list branches that can be fetched run git branch on machine-A (without options -r/-a). Commented Oct 22, 2023 at 19:32
  • Right. git branch on machine-A doesn't show the new branches. Is there a (reasonable) way to make the main idea work (to make all the changes fetchable from the bundle), or is it a lost cause from the start? Commented Oct 22, 2023 at 19:38

1 Answer 1

1

Since you want mention that you want to create a "mirror", clone with --mirror, which will get you the remote-tracking branches of the remote repository as well:

--mirror

Set up a mirror of the source repository. This implies --bare. Compared to --bare, --mirror not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update in the target repository.


Alternatively, specify additional refspecs for your remote:

git config --add remote.origin.fetch '+refs/remotes/extra/*:refs/remotes/extra/*' 

Or fetch them explicitly without any configuration:

git fetch origin '+refs/remotes/extra/*:refs/remotes/extra/*' 

Both forms will mirror the "extra" remote namespace of the remote repository locally when you fetch.

Sign up to request clarification or add additional context in comments.

2 Comments

Hmmm... you mean on machine-A? I tried it on machine-B so far only, but reading your response many times makes me believe that I totally misunderstood that flag, and my previous tries didn't make much sense. Let me give this a try.
Ahahahaaa.... your last suggestion works like a charm, thanks a lot

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.