2008-11-10 102 views
5

过了一段时间我想更新我的git repo,然后出了点问题。摆脱这种情况的正确方法是什么?如何更新包含子模块的git仓库?

[email protected]:~/src/psi/ $ git status 
iris: needs merge 
# On branch master 
# Changes to be committed: 
# (use "git reset HEAD <file>..." to unstage) 
# 
# modified: src/common.cpp 
# 
# Changed but not updated: 
# (use "git add <file>..." to update what will be committed) 
# 
# unmerged: iris 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# gupdate.sh 
[email protected]:~/src/psi/ $ git submodule status 
+cf237ef8f3d9dc058dbde47e6973e6388608ce60 iris (heads/master) 
+cf237ef8f3d9dc058dbde47e6973e6388608ce60 iris (heads/master) 
+cf237ef8f3d9dc058dbde47e6973e6388608ce60 iris (heads/master) 
[email protected]:~/src/psi/ $ cd iris 
[email protected]:~/src/psi/iris/ $ cat .git/HEAD 
cf237ef8f3d9dc058dbde47e6973e6388608ce60 

回答

5

当涉及到Git的子模块,几乎你遇到的任何问题可以通过解决:

1. deleting the submodule (rm -r iris) 
2. recreating it again (git submodule update) 

显然,如果你在本地做出了更改您的子模块,这将永久删除它们,因此,如果您有本地变化确保你先推动他们。

+1

有趣的是,我已经尝试过了,并没有真正的帮助,但它仍然表示在我从头开始更新“虹膜”后没有合并。最令人惊讶的是,这个问题在'git add iris'后消失了。 – mblsha 2008-12-09 20:51:43

3

我发布了一个类似question这里在stackoverflow和结束了自己回答,但我发现使用git reset HEAD iris工作我与子模块冲突的问题。