I am working on the esp-idf as submodule for my development and I have also integrated Jenkins for the same. It is running perfectly without shallow clone feature added over Jenkins. But, when I tried to clone submodule with shallow clone with depth 1, 5 to 10 it is throwing same error as below,
Cloning into 'platform/esp32'... fatal: reference is not a tree: 286202caa31b61c2182209f37f8069a0b60fb942 Unable to checkout '286202caa31b61c2182209f37f8069a0b60fb942' in submodule path 'SDK/platform/esp32' Failed to recurse into submodule path 'SDK'
However, it is working fine with git commands and without Jenkins.
Any help would be benefits to me.
My Jenkins setup as shown below,

This was also reported in Jenkins issue 60204 for git-scm plugin.
Make sure you have the latest version for that plugin.
Try and cleanup the Jenkins workspace associated with the job (with the help of the WS cleanup plugin)
As noted in JENKINS 63581:
The OP Bhargav Lalaji adds in the comments: