These three codes will make your life easier.
Today we’ll be showing you how to quickly exchange a lot of commits or branches between two repositories.
Our recommendation: Git Bundles. The two repositories don’t have to be connected to each other. This is practical if a direct pull isn’t possible due to access restrictions – for example, customer restrictions for security reasons – or a network outage. The bundles can be exchanged by e-mail after they are created, for example.
This is how to convert your commits or branches into a bundle:
The command
git bundle create ..
creates a bundle with the name given. This includes all commits from start hash to target hash. An example:
git bundle create sample.master.bundle 60c3d5834324ca6863cde231ee4d4eb5d4583282..master
Important: the two points must not be left out, otherwise everything up to the hash value given would be zipped into the bundle and this could be very big.
In the example above, all commits would be zipped into a bundle from the hash 60c3d5834324ca6863cde231ee4d4eb5d4583282 to the current master. BTW: the bundle is located in the folder in which the git command was executed.
The whole master branch can also be zipped into the bundle with the following command. You can simply leave out the start hash for this:
git bundle create sample.master.bundle master
This is how you import changes from a bundle:
For simplicity, before importing, the bundle should be copied into the target git repository. This means you then don’t have to specify any paths. You should first check whether the bundle is valid and matches the current repo:
git bundle verify sample.master.bundle
As an example, you’ll then receive the following output:
The bundle contains this ref: c14778c005226ae401f3e12c42a68772b155beef refs/heads/master The bundle requires this ref: 7003ade7b17fb2d57f431022681c40fbaca69f46 sample.master.bundle is okay
The message ‘sample.master.bundle is okay’ confirms that everything has worked and it can be imported. The command for this is:
git pull sample.master.bundle master
The syntax is:
git pull
If you don’t need all of the features from the bundle, you can also clone it in your own repo first:
git clone
Then you can cherry-pick the commits you want from this, for instance.
Now you know.
Have fun. Enjoy coding.
Your INNO coding team.