gitのorphanブランチを理解する

Github Pagesに使えそうなのでmanの該当箇所を訳してみました*1。=>原文
orphanブランチというのは、元のブランチからの歴史を受け継がず、gitリポジトリ内で新しく0から歴史を持つブランチです。新しくルートになり、親コミットを持ちません。
リポジトリの中から特定のファイルのみを公開したい場合などに使えそうです。

# 日本語として自然になるように努力はしてませんが、間違いは指摘していただければ直します

Synopsis

git checkout [-q] [-f] [-m] [[-b|-B|--orphan] ] []

Description

Create a new orphan branch, named , started from and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.
新しく という名前で から始まる orphan ブランチを作成し、それにスイッチする。
この新しいブランチ上での最初のコミットは親を持たず、他の全てのブランチとコミットから完全に切り離されている新しい歴史のルートになる。

The index and the working tree are adjusted as if you had previously run "git checkout ". This allows you to start a new history that records a set of paths similar to by easily running "git commit -a" to make the root commit.
あなたが直前に "git checkout " を実行していたら、インデックスとワーキングツリーは再設定される。
これは に似ているパスの集合を記録する新たな歴史を始め、簡単に "git commit -a" を実行することで新たなルートコミットを作成するためである。

This can be useful when you want to publish the tree from a commit without exposing its full history. You might want to do this to publish an open source branch of a project whose current tree is "clean", but whose full history contains proprietary or otherwise encumbered bits of code.
これは、コミットから完全な歴史を暴露することなく、ツリーを公開したいときに便利に使える。
あなたはこれを行うことで、カレントツリーが "クリーン" なあるプロジェクトのオープンソースブランチを公開したいかも知れない、しかしその完全な歴史には
プロプライエタリまたは他の阻害されるコードを含んでいる。

If you want to start a disconnected history that records a set of paths that is totally different from the one of ,
then you should clear the index and the working tree right after creating the orphan branch by running "git rm -rf ." from the top level of the working tree.
Afterwards you will be ready to prepare your new files, repopulating the working tree, by copying them from elsewhere, extracting a tarball, etc.
の一つから完全に切り離されたパスの集合の記録から断絶された歴史からを始めたいなら、
''orphan'' ブランチを作成した直後に ワーキングツリーのトップレベルから "git rm -rf ."を実行することで インデックスとワーキングツリーをクリアするべきである。
その後、新しいファイルの準備が出来たら、それらを他の場所からコピーし、tarballを展開し、etcすることでワーキングツリーを再度成長させる。

新しく歴史を始めるブランチを作るまとめ

  1. --orphan を指定してcheckout
    • git checkout --orphan
  2. 今までのブランチで管理しているファイルを消す
    • git rm -rf .
  3. 新しく管理するファイルをadd, commit

*1:結局自分で訳してみるのが早いんだよなぁ…