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
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With