DEV Community

Cover image for Exploring the charms of Git - Bundle
Sharkes Monken
Sharkes Monken

Posted on

Exploring the charms of Git - Bundle

Problem facing

One of the major issue that I had experienced, was having a laptop with no internet connection and had no ways to share the new changes made with my fellow team-mate who lives in Pakistan and since we both deploy our code into the same server this was a huge issue.

So as usual, git came in hand with a special command that would replicate local repos including specific branch or all branches into a repo container file which provides same capabilities as a normal working remote repo such as git fetch and git pull and the best part about it is that synchronisation can be performed without requiring direct ssh, or http protocol access between two machines.

Any Yes, some of you might argue "Why don't you just copy the folder", Well that's another story to tell but in my opinion, it's not effective enough to just be able to bundle working branches that includes certain references. Nevertheless, I tried it and as I expected, it did not work.

Alt text of image


Let's get to the command terminal and execute this working functionality.
The command is simple:

$ git bundle create repo.bundle --all

Here the bundle creation is being executed, repo.bundle being the file name. You can rename it how ever you want it to be. Note: --all will not include remote tracking branches similar to an ordinary clone command it wouldn't either.

Note: As no direct connection between the repositories exists, the user must specify a basis for the bundle that is held by the destination repository: the bundle assumes that all objects in the basis are already in the destination repository.

On your destination machine, after copying the file created from the previous step, execute the following:

$ git clone repo.bundle

Similar to a normal clone command -- init + fetch, and this will create a repo as a git repository.

Also, don't forget to update your remote URL reference in the .gitconfig file to point to your remote repo URL. The reason for this is that because during the bundling process, the remote reference defined as "Origin" tends to be updated and point to the resulting repository.

For more details on the command:

And that's it for me folks, happy coding.

Top comments (0)