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

时间:2012-03-26 16:42:08

标签: git git-submodules git-pull

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

git pull

这导致:

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.

尝试修复:

git pull origin master

输出:

From github.com:eteanga/smarty
 * branch            master     -> FETCH_HEAD
Updating 8e9a011..818ab3e
Fast-forward
[snip]

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

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

1 个答案:

答案 0 :(得分:18)

git submodule update之后,子模块中的HEAD被设置为超级项目中保存的子模块commit-hash。如果您要重置子模块中的HEAD以跟踪origin/master中的新提交,您首先必须结帐到master然后提取更改:

在子模块目录中:

git checkout master
git pull origin master