我的git子模块的状态是什么,我该如何清理它?

eoi*_*noc 10 git git-pull git-submodules

作为一个相对子模块菜鸟,我想从它的原点更新我的子模块,并做了:

git pull
Run Code Online (Sandbox Code Playgroud)

这导致:

remote: Counting objects: 111, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 57 (delta 54), reused 57 (delta 54)
Unpacking objects: 100% (57/57), done.
From github.com:eteanga/smarty
   8e9a011..818ab3e  master     -> origin/master
You are not currently on a branch, so I cannot use any
'branch.<branchname>.merge' in your configuration file.
Please specify which remote branch you want to use on the command
line and try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.
Run Code Online (Sandbox Code Playgroud)

试图解决:

git pull origin master
Run Code Online (Sandbox Code Playgroud)

输出:

From github.com:eteanga/smarty
 * branch            master     -> FETCH_HEAD
Updating 8e9a011..818ab3e
Fast-forward
[snip]
Run Code Online (Sandbox Code Playgroud)

现在看来我确实得到了更新的代码,我目前没有在任何分支上工作.

我应该怎么做才能正确更新我的子模块,我该怎么做才能修复这个当前状态?

oua*_*uah 19

在a之后git submodule update,将HEAD子模块中的子模块设置为保存在超级项目中的子模块.如果要重置HEAD子模块以跟踪新提交,origin/master首先必须签出master然后拉出更改:

在子模块目录中:

git checkout master
git pull origin master
Run Code Online (Sandbox Code Playgroud)

  • **只是打我**:在`git submodule foreach <command>`***之后运行上面的答案中的两个命令.不确定任何潜在的副作用,但...... (2认同)