0

同様の構成を持つ 3 つの git リポジトリと、それらの間にいくつかの重複したディレクトリがあります。それらは 1 つの大きなプロジェクトのサブプロジェクトです。

Proj1/
     .git/
     feature1_lib/
     feature1_app/
     feature1/       <- specific to Proj1

     feature2_lib/
     ...

Proj2/
     .git/
     feature1_lib/
     feature1_app/
     feature1/       <- specific to Proj2

     feature2_lib/
     ...

Proj3/
     .git/
     feature1_lib/
     feature1_app/
     feature1/       <- specific to Proj3

     feature3_lib/   <- specific to Proj3
     feature3_app/   <- specific to Proj3
     feature3/       <- specific to Proj3
     ...

それらは同時に開発されましたが、歴史はわずかに異なります。

Proj1/
      ...
      commit4   "Commit specific to Proj1."
      commit5   "Add code to feature1_lib."
      commit6   "Fix bugs in feature1_lib."
      commit7   "Refactoring in feature1_lib."
      ...

Proj2/
      ...
      commit6   "Import changes from Proj1."   <- after commit7 in Proj1
      commit7   "Commit specific to Proj2."
      commit8   "Fix bugs in feature2_lib."
      commit9   "Add code to feature2_lib."
      ...

等々。

現在、複製されたパーツをカットして接着するオプションを探しています。私はそれがこのように見えるべきだと思います

Proj1_2_common/
     .git/
     ...
Proj1_2_3_common/
     .git/
     ...
Proj1/
     .git/
     ...
Proj2/
     .git/
     ...
Proj3/
     .git/
     ...

サブツリーとサブモジュールについて読みましたが、完全には理解していません。プロジェクトで特定のディレクトリを指すことができるのに、なぜサブツリーを作成する必要があるのですか? つまり、 からサブツリーを作成する代わりに"feature1_lib/"、プロジェクトを再構成して を調べることができます"Proj1_2_3_common/feature1_lib/"

では、あなたの観点から、ここでより良いオプションは何ですか? 最も簡単なものは何ですか?このような厄介な歴史をどのように処理して、移動後にいくつかの参照を作成するのですか?

4

1 に答える 1

2

別の方法でアプリケーションを管理する必要があります。

  1. プロジェクトごとにリポジトリを作成する
Proj1/
  .git
Proj2/
  .git
Proj3/
  .git
  1. すべてのモジュール/機能のリポジトリを作成します
ProjModules/
  .git
  feature1/
  feature2/
  feature3/
  1. Git サブモジュールを使用して、3 つのプロジェクトに機能を含めます。
Proj1/
  .git
  .gitmodules
  vendor/
    ProjModules/
Proj2/
  .git
  .gitmodules
  vendor/
    ProjModules/
Proj3/
  .git
  .gitmodules
  vendor/
    ProjModules/

次に、 で変更を行い、これらの変更をおよびProj1/vendor/ProjModulesで伝播できます。Proj2/Proj3/

$ cd /Proj1/vendor/ProjModules/
$ touch newfile.txt
$ git add --all
$ git commit -m "New file !!"
$ git push origin master

$ cd ../../../Proj2/vendor/ProjModules/
$ git submodule foreach git pull

$ cd ../../../Proj3/vendor/ProjModules/
$ git submodule foreach git pull

別のアイデアは、モジュールごとにリポジトリを作成することです。これにより、必要なものだけをインポートできます。

于 2014-09-23T09:44:03.583 に答える