LoginSignup
2
2

More than 3 years have passed since last update.

Git で submodule を使ってマイクロサービスを開発している時に時々使うコマンドのオレオレ忘備録

Last updated at Posted at 2020-04-20

submodule 丸ごと clone

git clone --recursive git://example.com

いつ使う?

プロジェクトを初めて clone した時。

何が便利?

おそらく以下のコマンドをよく使うと思うが、これを1回で済ませることができる。
逆に言えば上記コマンドで --recursive をつけ忘れた時は、下記2つ目のコマンドを叩けば良い。

  • git clone git://example.com
  • git submodule update --init --recursive

submodule を全部最新化

git submodule update --init --recursive

いつ使う?

前述したやつ。
チーム等で開発してて、誰かが submodule を追加や更新した時に使う。

何が便利?

submodule の初期化(git submodule init)もしてくれるし、submodule の submodule とかも適切な状態にしてくれる。

submodule のブランチをすべてマスターに切り替えてコミットを最新にする

git submodule foreach git checkout master && git submodule foreach git pull origin master

いつ使う?

  • submodule 個々の最新をチェックしたい時。
  • submodule の開発をする時。
  • master からブランチを生やして作業したい時。

などなど。

注意

全ての submodule で master 最新にしたときに、サービスが正常動作するとは限らない。
(だから親の git で submodule コミット番号を管理しているわけだが)

2
2
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
2
2