2016-07-28 13 views
0

gitリポジトリを2つに分割したいと思います。 "プロジェクト"と "プロジェクト/ツール"。現在、(両方の特定の変化)は、この発展を反映して二つの枝(プロジェクト/ツールのプロジェクトのための「マスター」、「ツール」)がありますgitサブプロジェクトを2つのブランチから分離する

repo(s)  branch(es) 
    ------------- ------------- 
now project  master, tools 
         |  | 
new project  master  | 
    tools   master <--+ 

私はちょうど、それぞれのファイルは、それぞれに移動/削除できます"master"ブランチの "tools"ディレクトリを削除し、 "tools"ブランチの "tools"を除くすべてのブランチを削除して、ブランチとリポジトリの名前を変更してブランチから独立したリポジトリを作成します。

これを直接自動化するコマンドがありますか(git-subtree splitまたはgit filter-branch)?

最初にブランチをマージして、上記のいずれかのリンク(12)に記載されている手順に従ってください。

+0

を使用して、あなたのオリジナルのレポの二つのクローン、各ブランチのための1つを作成することであるかもしれませんその間に、私はブランチを "ツール"にクローンし、 "ツール"を抽出するために[2]で説明したフィルタ分岐メソッドを使用しました。 "project"では、サブディレクトリ "tools"を削除しました。 – handle

答えて

1

枝のそれぞれが唯一あなたが懸念しているファイルを触れた場合は、これを実行する一つの簡単な方法は、ちょうどにgit clone --single-branch --branch [master/tools]

--[no-]single-branch 
     Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary 
     branch remote's HEAD points at. When creating a shallow clone with the --depth option, this is the default, unless 
     --no-single-branch is given to fetch the histories near the tips of all branches. Further fetches into the resulting 
     repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If 
     the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is 
     created. 
+0

これに感謝しますが、私は最近「マスター」から「ツール」を分岐したので、彼らの歴史はほぼ同じだと思います。しかし、これは他の質問をもたらします、今私は本当にすべての歴史を必要としません。私はすぐにこれを試してみましょう。 Docs:https://git-scm.com/docs/git-clone#_options – handle

+0

上記のようにフィルターブランチ操作を行って、各ブランチでは必要のないものを取り除くことから始めても構いませんが、履歴が書き換えられます(それが懸念される場合)。 – DavidN

関連する問題