Git submodules 允许你在一个 Git 仓库内将另一个 Git 仓库作为子目录嵌入——用于将共享库或依赖项作为单独的仓库包含进来很有用。它们功能强大,但因复杂性而名声不佳,所以理解它们及其替代方案很有价值。
Submodules 是什么
A SUBMODULE is a reference to ANOTHER Git repository at a SPECIFIC COMMIT, embedded in
your repo as a subdirectory:
→ the parent repo records WHICH repo and WHICH commit (a pinned reference, not a copy)
→ the submodule is its own repo with its own history
→ Used to include shared libraries/components that are themselves versioned repos.
git submodule add <url> path/to/lib
git --recurse-submodules <url>
git submodule update --init --recursive
git submodule update --remote
