💡

Git Submoduleチートシート【Git Command編】

2022/09/07に公開

Git Submoduleチートシート【Git Command編】

Git Submoduleを含むプロジェクトのクローン

git clone ~.git --recursive

実行例

$ git clone https://github.com/nagaoka-aya/GitSubmoduleHundson_projectP.git --recursive
Cloning into 'GitSubmoduleHundson_projectP'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 0), reused 4 (delta 0), pack-reused 0
Receiving objects: 100% (7/7), done.
Submodule 'submodule/GitSubmoduleHundson_projectS' (https://github.com/nagaoka-aya/GitSubmoduleHundson_projectS.git) registered for path 'submodule/GitSubmoduleHundson_projectS'
Cloning into 'C:/work_tmp/0901_test/GitSubmoduleHundson_projectP/submodule/GitSubmoduleHundson_projectS'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Submodule path 'submodule/GitSubmoduleHundson_projectS': checked out 'b5a55c925d20b9a630ac47393997275b0d81538b'

Submoduleのコミット番号を確認する

git submodule

実行例

$ git submodule
 b5a55c925d20b9a630ac47393997275b0d81538b submodule/GitSubmoduleHundson_projectS (heads/main)

Submoduleを更新する

git submodule update

実行例

$ git submodule update
Submodule path 'submodule/GitSubmoduleHundson_projectS': checked out '1ebdb6c15c1ccdf8f41b1d2c9744155dd11da212'

Discussion