I know this question has been asked before, but I found all answers to just give me a quick solution to the problem, or a confusing explanation of why it happens and how it is actually solved.
This is how i encountered this error. One of my teammates pushed a change to a submodule in our repo. After pulling from master git status
showed new commits in our submodule:
modified: path/to/submodule/submodule_name (new commits)
So i decided to update the submodule by running
git submodule update path/to/submodule/submodule_name
-- here is the doc for this command
at this point i got the error
Fetched in submodule path 'path/to/submodule/submodule_name', but it did not contain ... Direct fetching of that commit failed
After googling i found different answers to my problem:
superuser is the link that got me closer to understanding the issue, and github just handed me the command to run to fix it -- git submodule sync
Now, i am still a bit confused on how the change showed up in my git status
yet when i try to update the server is not aware of the commit. And what does git submodule sync
do to make that commit available ?
You error message does mention:
dit did not contain ... Direct fetching of that commit failed
That is typical of a commit done in the submodule original cloned repository... not pushed back to its remote repo.
But the new state of the submodule repo was recorded in the parent repo, which was pushed.
Which means:
The parent repo reference a commit of the submodule repo which was never pushed to the submodule remote URL: an update from a clone would:
Your teammate did push a parent repo change (specifically a new state of the submodule) but did not push the commit(s) done within that submodule.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With