1 . 添加 submodule
1 2 3 4 5 6 7 8 9
| git submodule add git-url local-path
git commit -am"add submodule to git project" //
git push
git submodule init
|
2 . clone 带有submodule 的仓库 repos1
1 2 3 4 5 6 7 8 9
| git clone repos-1-url repos
cd repos
git submodule init
git submodule update
|
3 . git 项目中修改 submodule
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| cd submodule-path
git checkout master
...do somthing modify...
git commit -am"do modify"
git push
cd respo-root-path
git commit -am"update submodule"
git push
|
4 . 主项目更新 其他人 对 submodule做的修改
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| cd repos-submodule-path
git checkout master
git pull
//git submodule foreach git pull
.....
cd repos-paht
git commit -am"update submodule reference" //commit id
git push
|
记录 submodule 引用的仓库
记录submodule在主项目中的目录位置
记录submodule 的commit id
http://www.kafeitu.me/git/2012/03/27/git-submodule.html