是否有命令为所有现有的Git子模块设置相同的分支名称
git submodule add -b develop *
基本上我想等待递归设置.gitmodules
文件中每个模块的分支。
寻找递归的方法在.gitmodules文件中设置分支
使用Git 2.22(2019年第二季度,四年后),您将能够使用git submodule set-branch -b <abranch>
,因为“git submodule
”学习“set-branch
”子命令,允许修改submodule.*.branch
设置。
commit b57e811见commit c89c494,commit 7a4bb55(2019年2月8日)和Denton Liu (Denton-L
)(2019年2月7日)。
(由Junio C Hamano -- gitster
--合并于commit 01f8d78,2019年4月25日)
submodule
:教set-branch
子命令这教授
git-submodule
set-branch
子命令,它允许通过瓷器命令设置子模块的分支,而无需手动操作.gitmodules
文件。
在您的情况下,对于所有子模块,使用git submodule foreach
:
git submodule foreach 'git submodule set-branch --branch aBranch -- ${sm_path}'
git submodule foreach 'git submodule set-branch --default -- ${sm_path}'
(最后一行设置'master
'分支,which is the default)
在Git 2.22之前,你将使用我在“How can I specify a branch/tag when adding a Git submodule?”中提到的命令
git submodule foreach 'git config -f .gitmodules submodule.${sm_path}.branch <branch>'