In my repository, I have added a submodule by
git submodule add -b master https://something.something.git something
Now, whenever I hear there is an update in the submodule (remotely) I do
git submodule update --remote
And the submodule is updated locally. And if I clone my repo somewhere, I get the submodule in its latest state right away.
But if I run git status
on my repository after I updated the submodule, I get
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: something (new commits, modified content)
no changes added to commit (use "git add" and/or "git commit -a")
Why do I need to commit that some changes happened in the submodule when I am tracking the latest of the branch anyways? As I said, if I clone the repo somewhere else I get the updated submodules right away anyways, so what's this status message about?
Is there a way to make git ignore that there has been changes to the submodule?
Git is actually ignoring the changes to the submodule, but it does record what version of the submodule that is appropriate for this commit.
For instance, if you are on branch v1 of your repo and v1 of the submodule, then go ahead and make a v2 of the submodule and v2 of your repo (which is only comptaible with v2), then if you were to revert your repo back to v1, would also need to revert to use v1 of the submodule. Git doesn't track the actual changes that have happened before v1 and v2 of the submodule, but just commits a pointer to which commit the submodule was on.