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 不够。合上页面,先回答,再展开对照。
rm -rf 目录够吗?--recurse-submodules 或 submodule update --init。--remote 才会跟随远端。.gitmodules、索引和 .git/modules。
小程序版
微信扫码,随时查命令