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:
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:
The bundle requires this ref:
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:
If you don’t need all of the features from the bundle, you can also clone it in your own repo first:
Then you can cherry-pick the commits you want from this, for instance.
Now you know.
Have fun. Enjoy coding.
Your INNO-coding team.