git 使用笔记 (不定期更新中)

子模块 (Submodule)

添加

git submodule add [remotegiturl] [localdir]

更新

git submodule update --init --recursive

clone 时更新子模块

git clone [remotegiturl] --resuresive

远程更新(更新到最新)

submodule 不会detach到源的任何一个分支,而只是源的某一个commit,
使用 git submodule update --remote
将本地的子模块更新到最新。如果需要将远程仓库的子模块了更新到最新,可以先更新本地,再push到远程仓库:

git add .
git commit -m "submodule update"
git push

删除

git 没有提供删除子模块的命令

阅读更多