git 更新项目中子模块的版本

假设 .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

posted @ 2022-01-28 14:27  略略略——  阅读(3068)  评论(0编辑  收藏  举报