I'm working on a git project with several people and we have included an external library as a git submodule. We share a common remote that we regularly push to and pull from.
Since we first added this submodule there were some changes in it, so I did a git submodule update --remote
to update it to the newest version. That worked for me and I pushed this to our shared remote. The file at the location of the submodule where the reference to the commit is stored, has changed:
-Subproject commit <old-commit-hash>
+Subproject commit <new-commit-hash>
When my colleagues are pulling changes from our shared remote, they also receive the changed submodule, however this seems to be different from a change in a regular file, since it does not overwrite the old version (what I would expect), but it appears as change when they run git status
:
Changes not staged for commit:
modified: src/submodule (new commits)
So the file underneath changed (to the new revision that I pushed), but somehow git thinks that the local version of my colleague is newer. However, this is actually the old one, pointing to the previous revision that my colleagues still have.
Now, I like my colleagues, but sometimes they don't really pay attention and all they do is git add .
or git commit -a
which includes all changes and of course overwrites the changes to the submodule with the reference to the old submodule commit.
Is there a way to enforce this submodule update for all people that pull from this remote? Can this submodule reference file be treated like a normal file that is just updated normally?
Or do I have to tell my colleagues to pay more attention and do a git submodule update
from time to time?
I hope my question is clear. If not, please ask and I'll try to clarify.