8

複数のリポジトリを含むディレクトリがあり、次のようになります。

folder
|- repo1
|  |- .git
|  |- File1.txt
|- repo2
|  |- .git
|  |- File2.txt
|- repo3
|  |- .git
|  |- File3

それらを単一の git リポジトリに結合したかったので、次手順に従って実行しました。

これらの指示の後、私は次の構造を持っています:

folder
|- .git
|- repo1
|  |- File1.txt
|- repo2
|  |- File2.txt
|- repo3
|  |- File3

そして、それは素晴らしいことです。しかし、今ではメインブランチ (repo1 から) と履歴に 2 つの孤立したブランチがあります:

* Merge repo3
|\
| * Add third file
* Merge repo2
|\ 
| * Add second file
* Add first file

私が取得したいのは、このようなものです

* Merge repo 3
* Add third file
* Merge repo 2
* Add second file
* Add first file

またはさらに良い

* Add third file
* Add second file
* Add first file.

このようなことは可能ですか?そしてどうやって?


VonC が提供する回答の詳細。

私はこれから始めます:

$ git log --graph
*   commit 888bb0d7a81a40f8b42da7ad3f02103e898f5c1f
|\  Merge: cf85078 eab1269
| | Author: Bojan Delic <...>
| | Date:   Sun Oct 6 13:12:36 2013 +0200
| |
| |     Merge repo3
| |
| * commit eab1269be53929450c34c30416820c13a8058678
|   Author: Bojan Delic <...>
|   Date:   Sun Oct 6 13:07:39 2013 +0200
|
|       Add third file
|
*   commit cf85078ca96d52f2277ad7e4c6f45b04a38cf7ee
|\  Merge: 92fa311 42333f8
| | Author: Bojan Delic <...>
| | Date:   Sun Oct 6 13:12:33 2013 +0200
| |
| |     Merge repo2
| |
| * commit 42333f8589e20d29e5e444d5e16ff1a5d63b8288
|   Author: Bojan Delic <...>
|   Date:   Sun Oct 6 13:07:09 2013 +0200
|
|       Add second file
|
* commit 92fa3113507548a62407431188c308685f72865d
  Author: Bojan Delic <...>
  Date:   Sun Oct 6 13:06:39 2013 +0200

      Add first file

それから私は:

$ git branch -v
* master 888bb0d Merge repo3
$ git checkout -b branch2 eab1269be53929450c34c30416820c13a8058678
$ git checkout -b branch3 42333f8589e20d29e5e444d5e16ff1a5d63b8288
$ git checkout branch2
Switched to branch 'branch2'
$ git rebase master
First, rewinding head to replay your work on top of it...
Fast-forwarded branch2 to master.
$ git checkout master
Switched to branch 'master'
$ git merge branch2
Already up-to-date.
$ git checkout branch3
Switched to branch 'branch3'
$ git rebase master
First, rewinding head to replay your work on top of it...
Fast-forwarded branch3 to master.
$ git checkout master
Switched to branch 'master'
$ git merge branch3
Already up-to-date.

その後:

$ git log --graph
*   commit 888bb0d7a81a40f8b42da7ad3f02103e898f5c1f
|\  Merge: cf85078 eab1269
| | Author: Bojan Delic <...>
| | Date:   Sun Oct 6 13:12:36 2013 +0200
| |
| |     Merge repo3
| |
| * commit eab1269be53929450c34c30416820c13a8058678
|   Author: Bojan Delic <...>
|   Date:   Sun Oct 6 13:07:39 2013 +0200
|
|       Add third file
|
*   commit cf85078ca96d52f2277ad7e4c6f45b04a38cf7ee
|\  Merge: 92fa311 42333f8
| | Author: Bojan Delic <...>
| | Date:   Sun Oct 6 13:12:33 2013 +0200
| |
| |     Merge repo2
| |
| * commit 42333f8589e20d29e5e444d5e16ff1a5d63b8288
|   Author: Bojan Delic <...>
|   Date:   Sun Oct 6 13:07:09 2013 +0200
|
|       Add second file
|
* commit 92fa3113507548a62407431188c308685f72865d
  Author: Bojan Delic <...>
  Date:   Sun Oct 6 13:06:39 2013 +0200

      Add first file

$ git branch -a
  branch2
  branch3
* master
4

1 に答える 1