I have a project parent
with branches master
and work
. The master
branch is solely used to pull changes from an upstream repository and from time to time merge these changes into the work
branch. No changes will be done to the master branch.
The project has a submodule child
. At some point, after I merged changes from the master
branch to the work
branch, I noticed that the submodule pointers on the two branches differ. Whenever I switch from one branch to the other and then type git status
, I get, e.g. when switching back to master
:
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)
modified: child (new commits)
And the output for git diff
is something along the lines of:
diff --git a/child b/child
index 02232f9..5902a22 160000
--- a/child
+++ b/child
@@ -1 +1 @@
-Subproject commit abcdefdeadbeef0123456789
+Subproject commit 12381257dea0ffff018dead
Updating the submodule via git submodule update
"fixes" the immediate issue by making the change go away, but whenever I switch branches I will have a tainted index again. I want the submodule pointer of branch work
to always point to the same commit as the one on branch master
did when I last merged master
into work
, but after executing git submodule update
, I can't merge master
into work
, because git thinks that work
is already up-to-date.
How can I "repair" the submodule pointer in branch work
and make it point to the same commit as the one in branch master
does?
I know that there was a conflict issue once in the past with the submodule on branch work
, but I don't know anymore when and where it happened and therefore I can't really tell why exactly this situation occurred.
Is there a way to find out which commit to parent
changed the submodule pointer? According to this question, it's not possible?