简体   繁体   English

如何更新包含子模块的git仓库?

[英]How to update a git repo containing a submodule?

After some time I wanted to update my git repo, and then something went wrong. 过了一段时间我想更新我的git repo,然后出了点问题。 What is the proper way out of this situation? 出现这种情况的正确方法是什么?

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

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. 显然,如果您对子模块进行了本地更改,则会永久删除它们,因此如果您有本地更改,请确保先将其推送。

我在stackoverflow上发布了一个类似的问题 ,最后自己回答了问题,但我发现使用git reset HEAD iris解决我的子模块冲突问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM