1GIT-BUNDLE(1) Git Manual GIT-BUNDLE(1)
2
3
4
6 git-bundle - Move objects and refs by archive
7
9 git bundle create <file> <git-rev-list-args>
10 git bundle verify <file>
11 git bundle list-heads <file> [<refname>...]
12 git bundle unbundle <file> [<refname>...]
13
14
16 Some workflows require that one or more branches of development on one
17 machine be replicated on another machine, but the two machines cannot
18 be directly connected, and therefore the interactive git protocols
19 (git, ssh, rsync, http) cannot be used. This command provides support
20 for git fetch and git pull to operate by packaging objects and
21 references in an archive at the originating machine, then importing
22 those into another repository using git fetch and git pull after moving
23 the archive by some means (e.g., by sneakernet). As no direct
24 connection between the repositories exists, the user must specify a
25 basis for the bundle that is held by the destination repository: the
26 bundle assumes that all objects in the basis are already in the
27 destination repository.
28
30 create <file>
31 Used to create a bundle named file. This requires the
32 git-rev-list-args arguments to define the bundle contents.
33
34 verify <file>
35 Used to check that a bundle file is valid and will apply cleanly to
36 the current repository. This includes checks on the bundle format
37 itself as well as checking that the prerequisite commits exist and
38 are fully linked in the current repository. git bundle prints a
39 list of missing commits, if any, and exits with a non-zero status.
40
41 list-heads <file>
42 Lists the references defined in the bundle. If followed by a list
43 of references, only references matching those given are printed
44 out.
45
46 unbundle <file>
47 Passes the objects in the bundle to git index-pack for storage in
48 the repository, then prints the names of all defined references. If
49 a list of references is given, only references matching those in
50 the list are printed. This command is really plumbing, intended to
51 be called only by git fetch.
52
53 <git-rev-list-args>
54 A list of arguments, acceptable to git rev-parse and git rev-list
55 (and containing a named ref, see SPECIFYING REFERENCES below), that
56 specifies the specific objects and references to transport. For
57 example, master~10..master causes the current master reference to
58 be packaged along with all objects added since its 10th ancestor
59 commit. There is no explicit limit to the number of references and
60 objects that may be packaged.
61
62 [<refname>...]
63 A list of references used to limit the references reported as
64 available. This is principally of use to git fetch, which expects
65 to receive only those references asked for and not necessarily
66 everything in the pack (in this case, git bundle acts like git
67 fetch-pack).
68
70 git bundle will only package references that are shown by git show-ref:
71 this includes heads, tags, and remote heads. References such as
72 master~1 cannot be packaged, but are perfectly suitable for defining
73 the basis. More than one reference may be packaged, and more than one
74 basis can be specified. The objects packaged are those not contained in
75 the union of the given bases. Each basis can be specified explicitly
76 (e.g. ^master~10), or implicitly (e.g. master~10..master,
77 --since=10.days.ago master).
78
79 It is very important that the basis used be held by the destination. It
80 is okay to err on the side of caution, causing the bundle file to
81 contain objects already in the destination, as these are ignored when
82 unpacking at the destination.
83
85 Assume you want to transfer the history from a repository R1 on machine
86 A to another repository R2 on machine B. For whatever reason, direct
87 connection between A and B is not allowed, but we can move data from A
88 to B via some mechanism (CD, email, etc.). We want to update R2 with
89 development made on the branch master in R1.
90
91 To bootstrap the process, you can first create a bundle that does not
92 have any basis. You can use a tag to remember up to what commit you
93 last processed, in order to make it easy to later update the other
94 repository with an incremental bundle:
95
96 machineA$ cd R1
97 machineA$ git bundle create file.bundle master
98 machineA$ git tag -f lastR2bundle master
99
100
101 Then you transfer file.bundle to the target machine B. If you are
102 creating the repository on machine B, then you can clone from the
103 bundle as if it were a remote repository instead of creating an empty
104 repository and then pulling or fetching objects from the bundle:
105
106 machineB$ git clone /home/me/tmp/file.bundle R2
107
108
109 This will define a remote called "origin" in the resulting repository
110 that lets you fetch and pull from the bundle. The $GIT_DIR/config file
111 in R2 will have an entry like this:
112
113 [remote "origin"]
114 url = /home/me/tmp/file.bundle
115 fetch = refs/heads/*:refs/remotes/origin/*
116
117
118 To update the resulting mine.git repository, you can fetch or pull
119 after replacing the bundle stored at /home/me/tmp/file.bundle with
120 incremental updates.
121
122 After working some more in the original repository, you can create an
123 incremental bundle to update the other repository:
124
125 machineA$ cd R1
126 machineA$ git bundle create file.bundle lastR2bundle..master
127 machineA$ git tag -f lastR2bundle master
128
129
130 You then transfer the bundle to the other machine to replace
131 /home/me/tmp/file.bundle, and pull from it.
132
133 machineB$ cd R2
134 machineB$ git pull
135
136
137 If you know up to what commit the intended recipient repository should
138 have the necessary objects, you can use that knowledge to specify the
139 basis, giving a cut-off point to limit the revisions and objects that
140 go in the resulting bundle. The previous example used the lastR2bundle
141 tag for this purpose, but you can use any other options that you would
142 give to the git-log(1) command. Here are more examples:
143
144 You can use a tag that is present in both:
145
146 $ git bundle create mybundle v1.0.0..master
147
148
149 You can use a basis based on time:
150
151 $ git bundle create mybundle --since=10.days master
152
153
154 You can use the number of commits:
155
156 $ git bundle create mybundle -10 master
157
158
159 You can run git-bundle verify to see if you can extract from a bundle
160 that was created with a basis:
161
162 $ git bundle verify mybundle
163
164
165 This will list what commits you must have in order to extract from the
166 bundle and will error out if you do not have them.
167
168 A bundle from a recipient repository’s point of view is just like a
169 regular repository which it fetches or pulls from. You can, for
170 example, map references when fetching:
171
172 $ git fetch mybundle master:localRef
173
174
175 You can also see what references it offers:
176
177 $ git ls-remote mybundle
178
179
181 Written by Mark Levedahl <mdl123@verizon.net[1]>
182
184 Part of the git(1) suite
185
187 1. mdl123@verizon.net
188 mailto:mdl123@verizon.net
189
190
191
192Git 1.7.4.4 04/11/2011 GIT-BUNDLE(1)