abstract
- clone contains sub-module project
- Update sub-module
clone contains sub-module project
- method one
git clone url // 默认会包含子模块文件夹,但是子模块中没有文件
Enter the sub-module directory
cd directory // 进如子模块所在目录
git submodule init // 初始化子模块仓库
git submodule update // 检出文件到目录 但是本地还没有分支
- Second way (recommended)
git clone url --recursive // 自动初始化 更新子模块
Update a specific sub-modules
- Pulling updating submodule
cd submoduleDirectory
git fetch
git merge
Switch to the main project directory to see sub-module updates
cd ..
git diff --submodule
Each time you enter the trouble --submodule
to add a log
git config --global diff.submodule log
git diff
All sub-module project update
Under the project's home directory
git submodule update --remote // 默认 master 分支
Configuring other branches
git config -f .gitmodules submodule.submoduleName.branch branchName
View updates
git status
git config status.submodulesummary 1
git diff
Create a sub-module project
git submodule add url
git status // 配置文件 .gitmodules
git diff
git diff --submodule
git diff --cached --submodule
Work on the sub-module
git submodule update // 运行之后文件更新到了目录 但是本地没有默认分支,需要自己建立
git checkout master // 检出master分支
git submodule update --remote --merge //
// 修改模块文件内容之后 提交合并
git submodule update --remote --rebase
// 主项目文件夹下
git push --recurse-submodules=check // 推送前检查子模块 子模块没有推送就返回失败
git push --recurse-submodules=on-demand // 推送主项目前 检查子模块并推送子模块