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 job definition you uploaded as config.xml includes the "clean before checkout" behavior but does not include the "wipe workspace" behavior.
The "clean before checkout" behavior retains the existing git repository (the .git
directory) but removes untracked files.
It does that with the git clean -xfd
command.
If the workspace had been previously populated with repository content, the "clean before checkout" does not remove that previously created content.
The git plugin tries to reduce data transfer by retaining the git repository across multiple builds in the same workspace.
You would need to add "Wipe workspace" to assure that the two workspaces have the same content.
If wipe workspace still shows a difference, then it is likely that there is a difference due to the two versions of command line git being used.
The OP Bhargav Lalaji adds in the comments:
I was checking the git
command line on the different system and Jenkins was setup on other system.
After check the git versions both of them have different version.
After upgrade the git version from 2.7.4 to 2.34.1, I am able to checkout submodule with shallow clone with Jenkins