Snowcrash
Snowcrash

Reputation: 86097

git submodule update <name of submodule> - but still get modified: <name of submodule> (modified content)

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?

Upvotes: 3

Views: 3204

Answers (1)

larsks
larsks

Reputation: 311556

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:
    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'

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.

Upvotes: 8

Related Questions