我有一个子模块,当我执行 git status
时,我得到:
modified: <name of submodule> (modified content)
我跑:
git submodule update <name of submodule>
但仍然得到:
modified: <name of submodule> (modified content)
知道为什么吗?
最佳答案
modified content
消息的意思正是它所说的:您已经修改了该子模块目录中的文件。运行 git submodule update
不会丢弃本地更改(因为也许你想要那些)。 update
操作更像git pull
;只要不与您的本地更改冲突,就会应用新的更改。如果您的本地更改会导致冲突,您会看到如下内容:
error: Your local changes to the following files would be overwritten by checkout:
src/somefile.c
Please commit your changes or stash them before you switch branches.
Aborting
Unable to checkout '006d23ccca1375a973b7fae0cc351cedb41b812a' in submodule path 'name-of-submodule'
如果要放弃本地更改,可以使用--force
标志:
git submodule update --force
这将永久丢弃您在该子模块目录中所做的任何本地更改。
关于git submodule update <name of submodule> - 但仍然被修改 : <name of submodule> (modified content),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46911083/