跳到主要内容

Git Submodule

# 推荐
git config --global submodule.recurse true

# 添加
git submodule add https://example.com/submodule-repo.git path/to/submodule
# 已有
git submodule init
git submodule update
# clone 包含 submodule
git clone --recurse-submodules http://example.com/repo.git
# 全部更新
git submodule update --remote --recursive

.gitmodules

.git

gitdir: ../.git/modules/stub

FAQ

local submodule

git -c protocol.file.allow=always submodule add ~/gits/wenerme/kube-stub-cluster/.git stub

detached

# merge 或 rebase 即可
git submodule update --remote --merge
git submodule update --remote --rebase