jenkinsci / jenkinsci/git-plugin

[JENKINS-70195] submodule error: Your local changes to the following files would be overwritten by checkout

Open
#3,776 0 comments 0 reactions 0 assignees View on GitHub
component:git-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

I use pipline

 checkout([

$class: 'GitSCM',
userRemoteConfigs: [[url: env.GIT_PATH, credentialsId: 'loongle' ]],
branches: [[name: 'main']],
doGenerateSubmoduleConfigurations: false,
extensions: [[
$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false]],
submoduleCfg: []
])

First time normal execution after project creation,if i update the submodule, then it will have the following error

hudson.plugins.git.GitException: Command "git submodule update --init --recursive modules/data-management" returned status code 1:

stdout:
stderr: error: Your local changes to the following files would be overwritten by checkout:
Yoofast.HuarenSport.DataManagement.sln
src/Yoofast.HuarenSport.DataManagement.Domain/Yoofast.HuarenSport.DataManagement.Domain.csproj
Please commit your changes or stash them before you switch branches.
Aborting
Unable to checkout 'd352127edb42899e53550635530c396d1257c77e' in submodule path 'modules/data-management'

I think adding a parameter: --foce solves this problem, the final execution code might look something like this

git submodule update --init --recursive  --force modules/data-management

withCredentials cannot be used because there is no user name and password

withCredentials([gitUsernamePassword(credentialsId: 'my-credentials-id',

gitToolName: 'git-tool')]) {
powershell 'git push'
}

---
Originally reported by loongle, imported from: submodule error: Your local changes to the following files would be overwritten by checkout


  • status: Open
  • priority: Minor
  • component(s): git-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-02

Raw content of original issue

I use pipline


 checkout([

$class: 'GitSCM',
userRemoteConfigs: [[url: env.GIT_PATH, credentialsId: 'loongle' ]],
branches: [[name: 'main']],
doGenerateSubmoduleConfigurations: false,
extensions: [[
$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false]],
submoduleCfg: []
])

First time normal execution after project creation,if i update the submodule, then it will have the following error


hudson.plugins.git.GitException: Command "git submodule update --init --recursive modules/data-management" returned status code 1:

stdout:
stderr: error: Your local changes to the following files would be overwritten by checkout:
Yoofast.HuarenSport.DataManagement.sln
src/Yoofast.HuarenSport.DataManagement.Domain/Yoofast.HuarenSport.DataManagement.Domain.csproj
Please commit your changes or stash them before you switch branches.
Aborting
Unable to checkout 'd352127edb42899e53550635530c396d1257c77e' in submodule path 'modules/data-management'

I think adding a parameter: --foce solves this problem, the final execution code might look something like this


git submodule update --init --recursive  --force modules/data-management


withCredentials cannot be used because there is no user name and password



withCredentials([gitUsernamePassword(credentialsId: 'my-credentials-id',

gitToolName: 'git-tool')]) {
powershell 'git push'
}


Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.