Sometimes another person can not from the remote direct clone repository or because it is very large, clone is slow or other reasons, we may use the bundle command to package the Git repository, and then through a USB stick or other media copy to him, so he got a packaged warehouse can be unbundle into a warehouse, To achieve the purpose of sharing, which is sometimes very convenient.
Let's see what we can do:
First we go into the warehouse, git status and look at the current warehouse status.
Then start packing:
git bundle create Zhc.bundle HEAD Master
counting Objects:6, done.
Delta compression using up to 2 threads.
Compressing objects:100% (2/2), done.
Writing objects:100% (6/6), 447 bytes, done.
Total 6 (Delta 0), reused 0 (Delta 0)
HEAD Master shows that we want to generate all the information about the master branch. Then we saw that a zhc.bundle file was generated and the file was copied to someone else. After another person has this file, you can create a local repository based on it. Start unpacking the cost to the warehouse:
git clone zhc.bundler Repo
Then we saw one more Repo folder, which is the Git repository.
Sometimes we want to just pack some of these commits instead of all the commits on a branch, so we can use range commit to tell the bundle which commits to pack.
git bundle create Zhc.bundle master ^origin/master
This command means packing only those commits that are in master and not in the Origin/master branch.
Once you've got this bundle, you can verify it first:
git bundle verify. /zhc.bundle
The bundle contains 1 ref
84dx35f49 Refs/heads/master
The bundle requires these 1 ref
SD2FFE8SDF Hongchangfirst Commit
.. /zhc.bundle is okay
See that the bundle is complete and contains what you want, and then look at the contents of the bundle file to see what commits we can introduce.
git bundle list-heads. /zhc.bundle
Then we can begin to introduce:
git fetch: /zhc.bundle Master:zhc-branch
is to add the commits from the Master branch in the bundle to the local zhc-branch.
Original: http://blog.csdn.net/hongchangfirst/article/details/45579417
Author: Hongchangfirst
Hongchangfirst's homepage: http://blog.csdn.net/hongchangfirst
Three minutes to teach you to learn git (14) Offline Transfer warehouse