commit not found when syncing submodule

Viewed 36

I have an old code that has sub-modules. When I ran this command to update the submodules, I am getting the error that one of the submodules are not able to find the requested commit:

$ git submodule update --init --recursive
fatal: remote error: upload-pack: not our ref 1e07d0ce57c1bd5cf2e9b279deca2e959de88135
fatal: the remote end hung up unexpectedly
Fetched in submodule path 'linux', but it did not contain 1e07d0ce57c1bd5cf2e9b279deca2e959de88135. Direct fetching of that commit failed.

How can I find which submodule is this error coming from and how can I change the commit to something that can work (possibly some newer version of that commit which I believe was removed from the sub-module repository.

I believe this is related to the Linux kernel, as it is pointing to Linux but I am not sure. From what I could find the code was using Linux Kernal5.12.19 which is not supported and hence maybe it is already removed form the Linux kernel repository.

1 Answers

Here's a practical example. I've created a couple of example repositories to reproduce this problem, so that I have:

$ git clone upstream1 repo1
$ cd repo1
$ git submodule
-3c913516ad30ca52603cb319d68169939156523e example-submodule

If I try to update the submodule, it fails with a missing commit:

$ git submodule update --init
Submodule 'example-submodule' (/home/lars/tmp/repo/upstream2) registered for path 'example-submodule'
Cloning into '/home/lars/tmp/repo/tmp1/example-submodule'...
done.
fatal: git upload-pack: not our ref 3c913516ad30ca52603cb319d68169939156523e
fatal: remote error: upload-pack: not our ref 3c913516ad30ca52603cb319d68169939156523e
fatal: Fetched in submodule path 'example-submodule', but it did not contain 3c913516ad30ca52603cb319d68169939156523e. Direct fetching of that commit failed.

I happen to know that commit d91db5c146cd531b6b7c1a0e4445b98eb5ae02c5 is a valid commit and an appropriate replacement for 3c913516ad30ca52603cb319d68169939156523e, so to repair things I can check out that commit in the submodule:

$ cd example-submodule
$ git checkout d91db5c146cd531b6b7c1a0e4445b98eb5ae02c5
$ cd ..
$ git commit -m 'Updated submodule' example-submodule
Related