作为一个相对的子模块菜鸟,我想从它的原点更新我的子模块,并做了:
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]
现在看来我确实得到了更新的代码,但是我目前没有在任何分支上工作。
我应该怎么做才能正确更新我的子模块,我该怎么做才能解决这个当前状态?
答案 0 :(得分:18)
在git submodule update
之后,子模块中的HEAD
被设置为超级项目中保存的子模块commit-hash。如果您要重置子模块中的HEAD
以跟踪origin/master
中的新提交,您首先必须结帐到master
然后提取更改:
在子模块目录中:
git checkout master
git pull origin master