Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git子模块状态-如何在子模块中显示当前分支_Git_Git Submodules - Fatal编程技术网

Git子模块状态-如何在子模块中显示当前分支

Git子模块状态-如何在子模块中显示当前分支,git,git-submodules,Git,Git Submodules,使用以下命令检查主存储库中子模块的状态: git submodule status 生成输出(没有关于分支的明确信息): 是否可以检查子模块上的当前分支,而不使用: cd vendor/submodule1 git status cd ../submodule2 git status ? 此命令不起作用: git submodule status -b 答案隐藏在每个git子模块的中: git submodule foreach 'git status' 通过将此项分配给alias,始终

使用以下命令检查主存储库中子模块的状态:

git submodule status
生成输出(没有关于分支的明确信息):

是否可以检查子模块上的当前分支,而不使用:

cd vendor/submodule1
git status
cd ../submodule2
git status

此命令不起作用:

git submodule status -b

答案隐藏在每个git子模块的
中:

git submodule foreach 'git status'
通过将此项分配给alias,始终可以使其更简单:

git config --global alias.sb "submodule foreach \"git status\""
现在,
git sb
为您提供有关子模块中分支的详细信息:

Entering 'vendor/submodule1'
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Entering 'vendor/submodule2'
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

您可以运行
git子模块status--recursive

它给

  • 提交id
  • 项目中子模块的路径
  • 分支机构名称
Entering 'vendor/submodule1'
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Entering 'vendor/submodule2'
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean