GitHubのサブモジュールとは
自分が開発しているプロジェクトで他のプロジェクトを使用した時に使う。 Git submoduleを使えばリポジトリのサブディレクトリとして使え、それぞれ別プロジェクトとして管理ができる
サブモジュールの作り方
git submodule add リポジトリ名 ディレクトリ名
$ git submodule add https://github.com/hoge/hoge.git hoge
リポジトリを指定する場合は-bオプションをつける
$ git submodule add -b master https://github.com/hoge/hoge.git
これで.gitmodulesが作られます。
サブモジュールのブランチの変更方法
サブモジュールのブランチ名 -aオプションでサブモジュールのブランチもわかるので普通にcheckoutすれば良い
$ git branch -a
サブモジュールの更新
$ git pull -f
https://hacknote.jp/archives/8905/
$ git submodule foreach git pull origin master
サブモジュールの削除
$ git submodule deinit path $ git rm groupedTool
エラーが出たら指示通り-fオプションなどで消す もしsubmoduleのディレクトリ.git/modules/以下、.gitmodulesなどが残っていた場合、を消しておく
changes not staged for commit が出ていてPUSHできない場合 git add . してからcommit
参考
https://qiita.com/sotarok/items/0d525e568a6088f6f6bb