シンボリック リンクを使用できる場合 (たとえば、Windows を使用していない場合)、次core
のcore.php
ように設定できます。
# "base" repository layout:
core/
core.app
# each app repository layout:
base/
core/
core.php
core -> base/core/
core.php -> base/core.php
app/
各アプリ リポジトリでは、base/
ディレクトリは「ベース」リポジトリを使用するサブモジュールか、「ベース」リポジトリのサブツリー マージのいずれかです。
どちらの方法でも、特定のアプリのコンテキストでベース コードへの変更を開始し、後でそれらの変更をメインのベース リポジトリに戻すことができます。サブモジュールを使用する場合、新しいベース コミットを参照するアプリ コミットを発行する前に、常に新しいベース コミットを発行するように注意する必要があります (各アプリは「フラット」であり、実質的に独自のコピーを持っているため、サブツリー マージを使用する場合、これは問題ではありません)。ベース)。
サブモジュールを使用しないことにした場合、サードパーティのgit subtreeコマンドは、サブツリーのマージを管理するための非常に優れた方法のようです。
サブツリー
git init newapp
cd newapp
ln -s base/core
ln -s base/core.php
git add core core.php
git commit -m'point to base (to be added next)'
# hook up base
git subtree add --prefix=base git@git.example.com:me/app_base.git master
mkdir app
# edit app/bar.php
# update base
git subtree pull --prefix=base git@git.example.com:me/app_base.git master
.
|-- .git/
| |-- ...
| `-- ...
|-- app/
| `-- bar.php
|-- base/
| |-- core/
| | `-- foo.php
| `-- core.php
|-- core -> base/core/
`-- core.php -> base/core.php
サブモジュール
git init newapp
cd newapp
ln -s base/core
ln -s base/core.php
git add core core.php
git commit -m'point to base (to be added next)'
# hook up "base"
git submodule add git@git.example.com:me/app_base.git base
git commit -m'incorporate base'
mkdir app
# edit app/bar.php
# update base
(cd base && git fetch origin && git merge origin/master)
git add base
git commit -m'updated base'
.
|-- .git/
| |-- ...
| `-- ...
|-- .gitmodules
|-- app/
| `-- bar.php
|-- base/
| |-- .git/
| | |-- ...
| | `-- ...
| |-- core/
| | `-- foo.php
| `-- core.php
|-- core -> base/core/
`-- core.php -> base/core.php