Git Submodule Update - But Still Get Modified: (modified Content)

- 1 answer

I have a submodule and when I do git status I get:

modified:   <name of submodule> (modified content)

I run:

git submodule update <name of submodule> 

but still get:

modified:   <name of submodule> (modified content)

Any idea why?



The modified content message means exactly what it says: that you have modified files in that submodule directory. Running git submodule update will not discard local changes (because maybe you want those). The update operation is more like git pull; new changes will be applied as long as they don't conflict with your local changes. If your local changes would cause conflicts, you would see something like:

error: Your local changes to the following files would be overwritten by checkout:
Please commit your changes or stash them before you switch branches.
Unable to checkout '006d23ccca1375a973b7fae0cc351cedb41b812a' in submodule path 'name-of-submodule'

If you want to discard local changes, you can use the --force flag:

git submodule update --force

This will permanently discard any local changes you have made in that submodule directory.