Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 201
Snowcrash Avatar asked Jan 31 '26 05:01

Snowcrash


1 Answers

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.

like image 125
larsks Avatar answered Feb 03 '26 01:02

larsks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!