Hi Team,
I’m encountering an issue where my Netlify build fails to initialize private Git submodules, even though I’ve followed all the steps outlined in your documentation - Repository permissions and linking | Netlify Docs.
Issue Description:
-
My main repository has private Git submodules using SSH URLs (e.g.,
git@github.com:owner/private-repo.git
). -
I followed Netlify’s deploy key setup:
- Generated a Deploy Key from Netlify.
- Added the public key to the private submodule repositories in GitHub → Settings → Deploy Keys with read access.
-
However, during the build process, Netlify fails to initialize the submodules with the following error:
Failed during stage 'preparing repo': Error checking out submodules:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Troubleshooting Steps Taken:
- Verified Deploy Key Access
- The Netlify-generated key is correctly added as a deploy key to the private submodules.
- Running
ssh -T git@github.com
locally confirms that the key should work.
- Followed Netlify’s Documentation
- The private repositories are linked using SSH URLs, per the Netlify docs.
- I also ensured that submodules are not nested (recursive), as Netlify doesn’t support recursive submodules.
- Tried
GIT_SUBMODULE_STRATEGY=none
- Set
GIT_SUBMODULE_STRATEGY=none
in Netlify’s Environment Variables, but this didn’t prevent Netlify from attempting to initialize submodules before environment variables are picked up.
- Attempted to Skip Submodules Manually
Modified the Build Command to but the failure occurs before the build command executes.
rm -rf .git/modules/* frontend/ee server/ee && npm run build
- Tried Using HTTPS Instead of SSH
- Edited
.gitmodules
to usehttps://github.com/owner/private-repo.git
instead of SSH. - This didn’t work because the build server still tries to use SSH authentication.
Questions:
- Is there a way to ensure that the deploy key is correctly used for submodule authentication?
- Are there any additional debugging steps we can take to check if Netlify’s build environment is properly using the deploy key?