Git update submodule recursive

My project struture

ProjectA
-FrameworkA (submodule)
--Twig (submodule of FrameworkA)

How I can update submodule recursive? I already tried some git commands (on ProjectA root)

git submodule foreach git pull origin master
or
git submodule foreach --recursive git pull origin master

but cannot pull files of Twig


git submodule update --recursive

You will also probably want to use the --init option to which will make it initialize any uninitialized submodules:

git submodule update --init --recursive

Note: in some older versions of Git , if you use the --init option, already-initialized submodules may not be updated. In that case, you should also run the command without --init option.


我使用的方式是:

git submodule update --init --recursive
git submodule foreach --recursive git fetch
git submodule foreach git merge origin master

由于可能发生子模块的默认分支不是 master (这在我的情况中发生了很多),因此我将自动完成Git子模块的全部升级:

git submodule init
git submodule update
git submodule foreach 'git fetch origin; git checkout $(git rev-parse --abbrev-ref HEAD); git reset --hard origin/$(git rev-parse --abbrev-ref HEAD); git submodule update --recursive; git clean -dfx'
链接地址: http://www.djcxy.com/p/23604.html

上一篇: Git,如何将origin / master重置为提交?

下一篇: Git更新子模块递归