1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git submoduleで複数プロジェクトから同一のmodelを参照する

Last updated at Posted at 2018-10-26

目的

  • 複数プロジェクトから同一のmodelを参照したいため。
  • 今回はBのmodelをAからも参照させたい。

手順

  • submod_sample_a(以下A)とsubmod_sample_b(以下B)を用意する。
  • AにBをsubmoduleとして追加する
  • git submodule add git@github.com:xxxx/submod_sample_b.git submod_sample_b
  • Aで git status すると差分があるのでcommitする
  • Bで任意のファイルを追加してcommitしてpushする
  • Aで git submodule update --remote submod_sample_b これでfetch & merge出来る
  • Aで差分をgit addしてcommitする
  • developブランチを追従させるなら git config -f .gitmodules submodule.submod_sample_b.branch develop
  • Aでサブモジュール内のディレクトリにリンクを作成する。 ln -s ~/path/to/A/submod_sample_b/model(参照元の絶対パス) ~/path/to/A/model(参照先の絶対パス)

おまけ submoduleを含めてgit cloneする方法

  • git clone --recursive https://github.com/path/project
  • git submodule update --remote project_name

参照

Git - サブモジュール

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?