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