VS2022 - Git Changes with submodule always shows change

Viewed 602

I have a large solution (CoreServices) that utilizes a common library (Common). I have another large solution that also utilizes the common library so submodules seemed like the right answer. Most of the time, they are.

VS2022 is supposed to have support for these submodules. However, in my Git Changes window, it ALWAYS says I have a modified submodule reference - and it doesn't matter what branch I'm on. I can't stage the change...or undo it. Trying to commit tells me there are no files. I've thought maybe I'll just find wherever the commit hash is living on the superproject and update it but to no avail.

Can anyone explain this behavior?

Changes on Common - can't go forward or back - not even switching branche

1 Answers

For anyone looking at this.

There seems to be some different cases where this might happen. For me the submodule was stuck in a modified state and doing git restore modulename or git checkout modulename or any variations on git submodule update did nothing.

Resetting the submodule worked for me: git submodule foreach --recursive git reset --hard

Alternatively if that breaks you can try:

git submodule deinit -f .
# Initialize again
git submodule update --init --recursive
Related