Skip to content

Commit 042c11c

Browse files
committed
Translate bundling.asc
needs some proofreading(including the TBD title)
1 parent ce6767d commit 042c11c

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

book/07-git-tools/sections/bundling.asc

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
[[_bundling]]
2+
//////////////////////////
3+
=== Bundling
4+
//////////////////////////
25
=== Bundling
36
7+
//////////////////////////
48
Though we've covered the common ways to transfer Git data over a network (HTTP, SSH, etc), there is actually one more way to do so that is not commonly used but can actually be quite useful.
9+
//////////////////////////
10+
Git データをネットワーク越しに転送する方法(HTTP や SSH など)についてはすでに触れましたが、まだ紹介していない方法があります。あまり使われてはいませんが、とても便利な方法です。
511
12+
//////////////////////////
613
Git is capable of ``bundling'' it's data into a single file. This can be useful in various scenarios. Maybe your network is down and you want to send changes to your co-workers. Perhaps you're working somewhere offsite and don't have access to the local network for security reasons. Maybe your wireless/ethernet card just broke. Maybe you don't have access to a shared server for the moment, you want to email someone updates and you don't want to transfer 40 commits via `format-patch`.
14+
//////////////////////////
15+
Git では、データを ``bundling'' 、まとめて1つのファイルにできます。これが便利な場面はいくつもあるでしょう。例えば、ネットワークが落ちていて同僚に変更を送れないような場合。あるいは、いつもとは違う場所で仕事をしていて、セキュリティ上の理由によってネットワークへのアクセスが禁止されているのかもしれません。無線/有線LAN用のカードが壊れてしまったとか。もしくは、共有サーバーにはアクセス出来ないので作業内容をメールで送りたいけれど、かといって40ものコミットを `format-patch` を使って送りたくはない、ということかもしれません。
716
17+
//////////////////////////
818
This is where the `git bundle` command can be helpful. The `bundle` command will package up everything that would normally be pushed over the wire with a `git push` command into a binary file that you can email to someone or put on a flash drive, then unbundle into another repository.
19+
//////////////////////////
20+
そんなとき、`git bundle` コマンドが役に立つでしょう。このコマンドを使うと、`git push` コマンドで転送されるのと同内容のデータを単一のバイナリファイルにまとめてくれます。あとは、そのファイルをメールで送るか USB メモリに入れるなどしておいて、別のリポジトリ上で展開すればいいのです。
921
22+
//////////////////////////
1023
Let's see a simple example. Let's say you have a repository with two commits:
24+
//////////////////////////
25+
コミットが2つあるリポジトリを使って、簡単な例を紹介しましょう。
1126
1227
[source,console]
1328
----
@@ -25,7 +40,10 @@ Date: Wed Mar 10 07:34:01 2010 -0800
2540
first commit
2641
----
2742
43+
//////////////////////////
2844
If you want to send that repository to someone and you don't have access to a repository to push to, or simply don't want to set one up, you can bundle it with `git bundle create`.
45+
//////////////////////////
46+
このリポジトリを相手に送りたいのだけど、プッシュすべきリポジトリの書き込み権限が付与されていないとしましょう(あるいは、わざわざ権限を設定したくなかったのかもしれません)。そういった場合には、`git bundle create` コマンドを使うとそのリポジトリをまとめられます。
2947
3048
[source,console]
3149
----
@@ -37,11 +55,20 @@ Writing objects: 100% (6/6), 441 bytes, done.
3755
Total 6 (delta 0), reused 0 (delta 0)
3856
----
3957
58+
//////////////////////////
4059
Now you have a file named `repo.bundle` that has all the data needed to re-create the repository's `master` branch. With the `bundle` command you need to list out every reference or specific range of commits that you want to be included. If you intend for this to be cloned somewhere else, you should add HEAD as a reference as well as we've done here.
60+
//////////////////////////
61+
これで、`repo.bundle` というファイルが生成されました。対象リポジトリの `master` ブランチを復元できるだけのデータが含まれたファイルです。この `bundle` コマンドを使うには、まとめたい対象を範囲指定されたコミットや参照の形で指定する必要があります。クローン元となる予定であれば、HEAD を参照として追加しておくほうがよいでしょう(上記の例と同様)。
4162
63+
//////////////////////////
4264
You can email this `repo.bundle` file to someone else, or put it on a USB drive and walk it over.
65+
//////////////////////////
66+
この `repo.bundle` ファイルはメールで送ってもいいですし、USB メモリに入れて持っていってもかまいません。
4367
68+
//////////////////////////
4469
On the other side, say you are sent this `repo.bundle` file and want to work on the project. You can clone from the binary file into a directory, much like you would from a URL.
70+
//////////////////////////
71+
では、この `repo.bundle` ファイルを受け取った側はどうなるのでしょうか。該当のプロジェクトで作業をしたいとします。その場合、このバイナリファイルをディレクトリ上にクローンできます。URL を指定してクローンするのとなんら変わりありません。
4572
4673
[source,console]
4774
----
@@ -53,9 +80,16 @@ $ git log --oneline
5380
b1ec324 first commit
5481
----
5582
83+
//////////////////////////
5684
If you don't include HEAD in the references, you have to also specify `-b master` or whatever branch is included because otherwise it won't know what branch to check out.
85+
//////////////////////////
86+
まとめる対象として HEAD が含まれていないと、ここで、 `-b master` のように、なんらかのブランチを指定しなければなりません。そうしないと、どのブランチをチェックアウトすべきか、判断する術がないからです。
5787
88+
//////////////////////////
5889
Now let's say you do three commits on it and want to send the new commits back via a bundle on a USB stick or email.
90+
//////////////////////////
91+
続いて、さきほど受け取ったリポジトリにコミットを3つ追加しました。リポジトリをまとめて、USB メモリかメールで送り返してみましょう。
92+
5993
6094
[source,console]
6195
----
@@ -67,9 +101,15 @@ c99cf5b fourth commit - second repo
67101
b1ec324 first commit
68102
----
69103
104+
//////////////////////////
70105
First we need to determine the range of commits we want to include in the bundle. Unlike the network protocols which figure out the minimum set of data to transfer over the network for us, we'll have to figure this out manually. Now, you could just do the same thing and bundle the entire repository, which will work, but it's better to just bundle up the difference - just the three commits we just made locally.
106+
//////////////////////////
107+
それには、bundle としてまとめたいコミット範囲をまず決めます。ネットワークを使った方法であれば転送すべき範囲を最小限に自動で絞り込んでくれますが、ここでは手動で絞りこまねばなりません。最初に bundle を作ったときのようにリポジトリ全体をまとめてもかまいませんが、差分(この場合は追加したコミット3つ)だけをまとめるほうがよいでしょう。
71108
109+
//////////////////////////
72110
In order to do that, you'll have to calculate the difference. As we described in <<_commit_ranges>>, you can specify a range of commits in a number of ways. To get the three commits that we have in our master branch that weren't in the branch we originally cloned, we can use something like `origin/master..master` or `master ^origin/master`. You can test that with the `log` command.
111+
//////////////////////////
112+
そうするには、差分を割り出す必要があります。<<_commit_ranges>> で解説したとおり、コミット範囲を指定する方法はたくさんあります。手元の master ブランチにはあってクローン元のブランチにはないコミット3つを指定するには、`origin/master..master` や `master ^origin/master` などとするとよいでしょう。記述をテストするには、`log` コマンドを使います。
73113
74114
[source,console]
75115
----
@@ -79,7 +119,10 @@ c99cf5b fourth commit - second repo
79119
7011d3d third commit - second repo
80120
----
81121
122+
//////////////////////////
82123
So now that we have the list of commits we want to include in the bundle, let's bundle them up. We do that with the `git bundle create` command, giving it a filename we want our bundle to be and the range of commits we want to go into it.
124+
//////////////////////////
125+
対象のコミットがわかったので、ひとつにまとめてみましょう。バンドルファイルのファイル名と対象のコミット範囲を指定して `git bundle create` コマンドを実行します。
83126
84127
[source,console]
85128
----
@@ -91,9 +134,15 @@ Writing objects: 100% (9/9), 775 bytes, done.
91134
Total 9 (delta 0), reused 0 (delta 0)
92135
----
93136
137+
//////////////////////////
94138
Now we have a `commits.bundle` file in our directory. If we take that and send it to our partner, she can then import it into the original repository, even if more work has been done there in the meantime.
139+
//////////////////////////
140+
このようにすると、リポジトリ内に `commits.bundle` ファイルが生成されます。そのファイルを送り返すと、受け取った相手は元のリポジトリにその内容を取り込めます。そのリポジトリに他の作業内容が追加されていたとしても問題にはなりません。
95141
142+
//////////////////////////
96143
When she gets the bundle, she can inspect it to see what it contains before she imports it into her repository. The first command is the `bundle verify` command that will make sure the file is actually a valid Git bundle and that you have all the necessary ancestors to reconstitute it properly.
144+
//////////////////////////
145+
バンドルファイルを受け取った側は、それを検査して中身を確認できます。その後、元のリポジトリに取り込めばよいのです。そのためのコマンドが `bundle verify` で、これを実行すると、そのファイルが Git のバンドルファイルであること、そのバンドルファイルを取り込むのに必要となる祖先が手元のリポジトリにあるかどうかを検査できます。
97146
98147
[source,console]
99148
----
@@ -105,7 +154,10 @@ The bundle requires these 1 ref
105154
../commits.bundle is okay
106155
----
107156
157+
//////////////////////////
108158
If the bundler had created a bundle of just the last two commits they had done, rather than all three, the original repository would not be able to import it, since it is missing requisite history. The `verify` command would have looked like this instead:
159+
//////////////////////////
160+
バンドルファイルを作る側が、自分たちが追加したコミット3つのうち2つしかバンドルファイルに含めなかったとしたらどうなるのでしょうか?その場合、元のリポジトリはそれを取り込めません。歴史を再構成するために必要なデータが揃っていないからです。もし `verify` コマンドを実行すれば、以下のようになるでしょう。
109161
110162
[source,console]
111163
----
@@ -114,15 +166,21 @@ error: Repository lacks these prerequisite commits:
114166
error: 7011d3d8fc200abe0ad561c011c3852a4b7bbe95 third commit - second repo
115167
----
116168
169+
//////////////////////////
117170
However, our first bundle is valid, so we can fetch in commits from it. If you want to see what branches are in the bundle that can be imported, there is also a command to just list the heads:
171+
//////////////////////////
172+
この例では、1つめに検査したバンドルファイルは有効だったので、コミットを取り出せます。バンドルファイルに含まれている取り込み可能なブランチを知りたければ、ブランチ参照をリストアップするためのコマンドもあります。
118173
119174
[source,console]
120175
----
121176
$ git bundle list-heads ../commits.bundle
122177
71b84daaf49abed142a373b6e5c59a22dc6560dc refs/heads/master
123178
----
124179
180+
//////////////////////////
125181
The `verify` sub-command will tell you the heads as well. The point is to see what can be pulled in, so you can use the `fetch` or `pull` commands to import commits from this bundle. Here we'll fetch the 'master' branch of the bundle to a branch named 'other-master' in our repository:
182+
//////////////////////////
183+
`verify` サブコマンドを使っても、同様にブランチ参照をリストアップできます。大事なのは、何が取り込めるのかを確認する、ということです。そうすれば、`fetch` や `pull` コマンドを使ってバンドルファイルからコミットを取り込めるからです。ここでは、バンドルファイルの 'master' ブランチを、手元のリポジトリの 'other-master' ブランチに取り込んでみましょう。
126184
127185
[source,console]
128186
----
@@ -131,7 +189,10 @@ From ../commits.bundle
131189
* [new branch] master -> other-master
132190
----
133191
192+
//////////////////////////
134193
Now we can see that we have the imported commits on the 'other-master' branch as well as any commits we've done in the meantime in our own 'master' branch.
194+
//////////////////////////
195+
そうすると、'master' ブランチに追加したコミットはそのままで、'other-master' ブランチ上にバンドルファイルからコミットが取り込まれていることがわかります。
135196
136197
[source,console]
137198
----
@@ -145,4 +206,7 @@ $ git log --oneline --decorate --graph --all
145206
* b1ec324 first commit
146207
----
147208
209+
//////////////////////////
148210
So, `git bundle` can be really useful for sharing or doing network-type operations when you don't have the proper network or shared repository to do so.
211+
//////////////////////////
212+
このように、データの共有やネットワークを使う作業に `git bundle` はとても便利なコマンドです。特にネットワーク環境や共有リポジトリがない状態ではそれを実感できるでしょう。

0 commit comments

Comments
 (0)