4

I have two git repositories which I need to synchronize without having direct network connection between them.

I cannot use git fetch or git push as-is because both of them require that direct connection. Patchfiles also don't seem to be a viable option because they lose commit tree structure. Although, I've discovered that git uses git pack-objects and git unpack-objects under the hood to generate and consume pack-files.

Can I somehow make Git generate that packfile for me (given I provide commit range I want) and then consume it? Or maybe there's some way to preserve structure in patches? Or maybe there's some other approach?

Thanks

5

1 Answer 1

6

Try git bundle.

A bundle works as a read-only repository. To create a bundle of the branch master,

git bundle create foo.bundle master 

Then you can move foo.bundle to the machine where the other repository is and read/fetch the metadata you need.

cd <the_other_repository> git checkout master git pull <path_to_foo.bundle> master # or maybe you want to cherry-pick a single commit git fetch <path_to_foo.bundle> master git cherry-pick <commit> 
Sign up to request clarification or add additional context in comments.

3 Comments

Looks really promising. Will try and report later.
Thanks! that's definitely the solution I've been looking for.
If you want to clone a new repository from a bundle, you need to include "HEAD" as one of the branches in the bundle.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.