假設 .gitmodules 是這樣的:
[submodule "abc"]
path = abc
url=git@github.com:me/abc.git
之前一直以為有了這個文件子模塊就會自動拉取最新版本的代碼,其實不是的,需要手動指定和變更。
正確做法
git submodule update --remote --recursive- 進入子模塊的目錄
- 檢出到想要的分支或提交
- (拉取最新代碼)
- 退出到根目錄, 把對子模塊的修改提交。
示例
cd mod
git checkout master
git pull origin master
cd ..
git add mod
git commit -m "Updating the submodule 'mod' to the latest version"
git push origin master
參考
https://stackoverflow.com/questions/5828324/update-git-submodule-to-latest-commit-on-origin
