Project

General

Profile

Git子模块

# 添加子模块
git submodule add -b your-target-branch <repository-url> path/to/your/submodule

# 更新到当前
git submodule update --init --recursive

# 更新到最新:
git pull
git submodule update --remote

# 主项目提交
git add path/to/your/submodule
git commit -m "Update submodule reference" 

# 其它
git submodule foreach 'git checkout your-target-branch'
git submodule foreach 'git pull origin your-target-branch'
git submodule foreach 'git add . && git commit -m "说明"'
git submodule foreach 'git push'
git submodule foreach 'git status'
git submodule foreach 'git branch'

# 使用 --remote 选项时,是从远程分支拉取最新的提交,而不是更新到当前提交。
# 使用 --recursive 选项时,是初始化和更新所有子模块及其嵌套子模块,确保它们与主项目的提交一致。