如何更新包含子模块的 git repo?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/278564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to update a git repo containing a submodule?
提问by mblsha
After some time I wanted to update my git repo, and then something went wrong. What is the proper way out of this situation?
一段时间后,我想更新我的 git 存储库,然后出了点问题。摆脱这种情况的正确方法是什么?
mblsha@siruba:~/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
mblsha@siruba:~/src/psi/ $ git submodule status
+cf237ef8f3d9dc058dbde47e6973e6388608ce60 iris (heads/master)
+cf237ef8f3d9dc058dbde47e6973e6388608ce60 iris (heads/master)
+cf237ef8f3d9dc058dbde47e6973e6388608ce60 iris (heads/master)
mblsha@siruba:~/src/psi/ $ cd iris
mblsha@siruba:~/src/psi/iris/ $ cat .git/HEAD
cf237ef8f3d9dc058dbde47e6973e6388608ce60
采纳答案by Daniel Lucraft
When it comes to git submodules, almost any problem you encounter can be solved by:
谈到 git 子模块,你遇到的几乎任何问题都可以通过以下方式解决:
1. deleting the submodule (rm -r iris)
2. recreating it again (git submodule update)
Obviously if you have made local changes to your submodule this will DELETE them PERMANENTLY, so if you have local changes make sure you have pushed them first.
显然,如果您对子模块进行了本地更改,这将永久删除它们,因此如果您有本地更改,请确保先推送它们。

