How can I clean up submodules on switching branches?
Answered
I have a project with two branches. One branch has a number of submodules, the other only has one. When TeamCity switches from the branch that has submodules to the one that doesn't, it leaves the submodules in place which causes the build to fail. This is despite the 'clean' policy set to remove all non-ignored files.
From what I understand from this StackOverflow post, this is normal behaviour with git, and to solve it you need to run "git clean -f -f -d".
I can't see any way to do this with TeamCity, so I'm having to manually delete these folders, which is not great!
Please sign in to leave a comment.
Hello Edwin,
Apologies for the delayed response here.
I have found a related discussion on the matter: https://youtrack.jetbrains.com/issue/TW-38603
As per our development team response in the comments, earlier we have considered to run git clean with -ff flag when clean checkout is requested but the changes were rolled back because of the break in business logic with multiple VCS roots. As a workaround, following ~/.gitconfig change on every agent where you need a -ff behaviour could be applied:
After that a single -f flag in git clean command would start working as -ff.
Would this work for you?