Git 子模块管理
git submodule 在一个仓库里引用另一个仓库的特定提交。它适合复用公共库或分离部署配置,但克隆、更新和删除都比普通目录复杂。
git submodule add https://github.com/example/lib.git vendor/lib
git submodule status
git submodule init
git submodule update
git submodule update --init --recursive
git submodule update --remote
git submodule sync
git submodule foreach 'git pull --ff-only'
git submodule deinit vendor/lib
git submodule set-url vendor/lib https://github.com/example/lib2.git
--recurse-submodules 或 submodule update --init。--remote 才会跟随远端。.gitmodules 要提交;子模块目录本身不存对象,只存 gitlink。.gitmodules、索引和 .git/modules,只 rm -rf 不够。git — 版本控制git-worktree — 多工作区git-lfs — 大文件