Skip to content

Commit 8aa7eeb

Browse files
Nanako Shiraishigitster
authored andcommitted
git-bundle doc: update examples
This rewrites the example part of the bundle doucmentation to follow the suggestion made by Junio during a recent discussion (gmane 108030). Instead of just showing different ways to create and use bundles in a disconnected fashion, the rewritten example first shows the simplest "full cycle" of sneakernet workflow, and then introduces various variations. The words are mostly taken from Junio's outline. I only reformatted them and proofread to make sure the end result flows naturally. Signed-off-by: Nanako Shiraishi <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34263de commit 8aa7eeb

File tree

1 file changed

+84
-48
lines changed

1 file changed

+84
-48
lines changed

Documentation/git-bundle.txt

Lines changed: 84 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ defining the basis. More than one reference may be packaged, and more
8484
than one basis can be specified. The objects packaged are those not
8585
contained in the union of the given bases. Each basis can be
8686
specified explicitly (e.g., ^master~10), or implicitly (e.g.,
87-
master~10..master, master --since=10.days.ago).
87+
master~10..master, --since=10.days.ago master).
8888

8989
It is very important that the basis used be held by the destination.
9090
It is okay to err on the side of conservatism, causing the bundle file
@@ -94,75 +94,111 @@ when unpacking at the destination.
9494
EXAMPLE
9595
-------
9696

97-
Assume two repositories exist as R1 on machine A, and R2 on machine B.
97+
Assume you want to transfer the history from a repository R1 on machine A
98+
to another repository R2 on machine B.
9899
For whatever reason, direct connection between A and B is not allowed,
99100
but we can move data from A to B via some mechanism (CD, email, etc).
100101
We want to update R2 with developments made on branch master in R1.
101102

102-
To create the bundle you have to specify the basis. You have some options:
103+
To bootstrap the process, you can first create a bundle that doesn't have
104+
any basis. You can use a tag to remember up to what commit you sent out
105+
in order to make it easy to later update the other repository with
106+
incremental bundle,
103107

104-
- Without basis.
105-
+
106-
This is useful when sending the whole history.
108+
----------------
109+
machineA$ cd R1
110+
machineA$ git bundle create file.bdl master
111+
machineA$ git tag -f lastR2bundle master
112+
----------------
107113

108-
------------
109-
$ git bundle create mybundle master
110-
------------
114+
Then you sneakernet file.bdl to the target machine B. Because you don't
115+
have to have any object to extract objects from such a bundle, not only
116+
you can fetch/pull from a bundle, you can clone from it as if it was a
117+
remote repository.
111118

112-
- Using temporally tags.
113-
+
114-
We set a tag in R1 (lastR2bundle) after the previous such transport,
115-
and move it afterwards to help build the bundle.
119+
----------------
120+
machineB$ git clone /home/me/tmp/file.bdl R2
121+
----------------
116122

117-
------------
118-
$ git bundle create mybundle master ^lastR2bundle
119-
$ git tag -f lastR2bundle master
120-
------------
123+
This will define a remote called "origin" in the resulting repository that
124+
lets you fetch and pull from the bundle. $GIT_DIR/config file in R2 may
125+
have an entry like this:
121126

122-
- Using a tag present in both repositories
127+
------------------------
128+
[remote "origin"]
129+
url = /home/me/tmp/file.bdl
130+
fetch = refs/heads/*:refs/remotes/origin/*
131+
------------------------
132+
133+
You can fetch/pull to update the resulting mine.git repository after
134+
replacing the bundle you store at /home/me/tmp/file.bdl with incremental
135+
updates from here on.
136+
137+
After working more in the original repository, you can create an
138+
incremental bundle to update the other:
139+
140+
----------------
141+
machineA$ cd R1
142+
machineA$ git bundle create file.bdl lastR2bundle..master
143+
machineA$ git tag -f lastR2bundle master
144+
----------------
145+
146+
and sneakernet it to the other machine to replace /home/me/tmp/file.bdl,
147+
and pull from it.
148+
149+
----------------
150+
machineB$ cd R2
151+
machineB$ git pull
152+
----------------
123153

124-
------------
125-
$ git bundle create mybundle master ^v1.0.0
126-
------------
154+
If you know up to what commit the intended recipient repository should
155+
have the necessary objects for, you can use that knowledge to specify the
156+
basis, giving a cut-off point to limit the revisions and objects that go
157+
in the resulting bundle. The previous example used lastR2bundle tag
158+
for this purpose, but you can use other options you would give to
159+
the linkgit:git-log[1] command. Here are more examples:
127160

128-
- A basis based on time.
161+
You can use a tag that is present in both.
129162

130-
------------
131-
$ git bundle create mybundle master --since=10.days.ago
132-
------------
163+
----------------
164+
$ git bundle create mybundle v1.0.0..master
165+
----------------
133166

134-
- With a limit on the number of commits
167+
You can use a basis based on time.
135168

136-
------------
137-
$ git bundle create mybundle master -n 10
138-
------------
169+
----------------
170+
$ git bundle create mybundle --since=10.days master
171+
----------------
139172

140-
Then you move mybundle from A to B, and in R2 on B:
173+
Or you can use the number of commits.
141174

142-
------------
175+
----------------
176+
$ git bundle create mybundle -10 master
177+
----------------
178+
179+
You can run `git-bundle verify` to see if you can extract from a bundle
180+
that was created with a basis.
181+
182+
----------------
143183
$ git bundle verify mybundle
144-
$ git fetch mybundle master:localRef
145-
------------
184+
----------------
146185

147-
With something like this in the config in R2:
186+
This will list what commits you must have in order to extract from the
187+
bundle and will error out if you don't have them.
148188

149-
------------------------
150-
[remote "bundle"]
151-
url = /home/me/tmp/file.bdl
152-
fetch = refs/heads/*:refs/remotes/origin/*
153-
------------------------
189+
A bundle from a recipient repository's point of view is just like a
190+
regular repository it fetches/pulls from. You can for example map
191+
refs, like this example, when fetching:
154192

155-
You can first sneakernet the bundle file to ~/tmp/file.bdl and
156-
then these commands on machine B:
193+
----------------
194+
$ git fetch mybundle master:localRef
195+
----------------
157196

158-
------------
159-
$ git ls-remote bundle
160-
$ git fetch bundle
161-
$ git pull bundle
162-
------------
197+
Or see what refs it offers.
163198

164-
would treat it as if it is talking with a remote side over the
165-
network.
199+
----------------
200+
$ git ls-remote mybundle
201+
----------------
166202

167203
Author
168204
------

0 commit comments

Comments
 (0)