Git config for private submodule

Hi everyone!

I’m wondering if it is possible to have my hugo theme as a private submodule with https.

From what I understand, this is not possible. so to work around I thought that I can simply set a git config to use ssh instead of https just for netlify.

So I added it to my netlify.toml. The command is now:

command = "git config --global url.'git@github.com:'.insteadOf 'https://github.com/' ; hugo --gc --minify"

10:42:22 PM: Build ready to start
10:42:24 PM: build-image version: 8925038cf853b22d6397cdcb9904ac88b66bb383 (focal)
10:42:24 PM: build-image tag: v4.5.0
10:42:24 PM: buildbot version: c0e8ffa453e19757f422ac0b6b14bc1b57e53b59
10:42:24 PM: Fetching cached dependencies
10:42:24 PM: Failed to fetch cache, continuing with build
10:42:24 PM: Starting to prepare the repo for build
10:42:24 PM: Netlify Large Media is enabled, running git commands with GIT_LFS_SKIP_SMUDGE=1
10:42:24 PM: No cached dependencies found. Cloning fresh repo
10:42:24 PM: git clone https://github.com/berot3/DanFerestre.com
10:42:25 PM: Preparing Git Reference pull/22/head
10:42:26 PM: Error checking out submodules: Submodule 'themes/icelab-hugo' (https://github.com/berot3/DanFerestre.com-theme.git) registered for path 'themes/icelab-hugo'Cloning into '/opt/build/repo/themes/icelab-hugo'...fatal: could not read Username for 'https://github.com': No such device or addressfatal: clone of 'https://github.com/berot3/DanFerestre.com-theme.git' into submodule path '/opt/build/repo/themes/icelab-hugo' failedFailed to clone 'themes/icelab-hugo'. Retry scheduledCloning into '/opt/build/repo/themes/icelab-hugo'...fatal: could not read Username for 'https://github.com': No such device or addressfatal: clone of 'https://github.com/berot3/DanFerestre.com-theme.git' into submodule path '/opt/build/repo/themes/icelab-hugo' failedFailed to clone 'themes/icelab-hugo' a second time, aborting
10:42:26 PM: Creating deploy upload records
10:42:26 PM: Failing build: Failed to prepare repo
10:42:26 PM: Failed during stage 'preparing repo': Error checking out submodules: Submodule 'themes/icelab-hugo' (https://github.com/berot3/DanFerestre.com-theme.git) registered for path 'themes/icelab-hugo'Cloning into '/opt/build/repo/themes/icelab-hugo'...fatal: could not read Username for 'https://github.com': No such device or addressfatal: clone of 'https://github.com/berot3/DanFerestre.com-theme.git' into submodule path '/opt/build/repo/themes/icelab-hugo' failedFailed to clone 'themes/icelab-hugo'. Retry scheduledCloning into '/opt/build/repo/themes/icelab-hugo'...fatal: could not read Username for 'https://github.com': No such device or addressfatal: clone of 'https://github.com/berot3/DanFerestre.com-theme.git' into submodule path '/opt/build/repo/themes/icelab-hugo' failedFailed to clone 'themes/icelab-hugo' a second time, aborting: exit status 1
10:42:26 PM: Finished processing build request in 2.725960944s

I also tried to use environment, but without luck:

GIT_CONFIG_PARAMETERS="'url.git@github.com.insteadOf=https://github.com'"

Hi @berot3

You might find the following support guide helpful

Thanks a lot for the quick reply.

Got it. So I can not set git-configs for deploys? So there is no way around using ssh for submodules.

I think you should maybe think about it once more. SSH for submodules is nice to have, but everyone is using https.
And looking at the competition like render, they do support https for submodules ( even though I didn’t see if they also support ssh for submodules).

Maybe one solution would be to use relative paths? Than Netlify could use ssh and everywhere else I could use https…

I just tried it and netlify is reading the path wrong:
https://app.netlify.com/sites/danferestre-com/deploys/61a4fab3f77d5300080394e9

6:07:15 PM: Build ready to start
6:07:17 PM: build-image version: 8925038cf853b22d6397cdcb9904ac88b66bb383 (focal)
6:07:17 PM: build-image tag: v4.5.0
6:07:17 PM: buildbot version: 8a3c565585bf7313c6ec1052fd212f83330bb917
6:07:17 PM: Fetching cached dependencies
6:07:17 PM: Failed to fetch cache, continuing with build
6:07:17 PM: Starting to prepare the repo for build
6:07:17 PM: Netlify Large Media is enabled, running git commands with GIT_LFS_SKIP_SMUDGE=1
6:07:18 PM: No cached dependencies found. Cloning fresh repo
6:07:18 PM: git clone https://github.com/berot3/DanFerestre.com
6:07:19 PM: Preparing Git Reference pull/22/head
6:07:19 PM: Error checking out submodules: warning: could not look up configuration 'remote.origin.url'. Assuming this repository is its own authoritative upstream.Submodule 'themes/icelab-hugo' (/opt/build/DanFerestre.com-theme.git) registered for path 'themes/icelab-hugo'fatal: repository '/opt/build/DanFerestre.com-theme.git' does not existfatal: clone of '/opt/build/DanFerestre.com-theme.git' into submodule path '/opt/build/repo/themes/icelab-hugo' failedFailed to clone 'themes/icelab-hugo'. Retry scheduledfatal: repository '/opt/build/DanFerestre.com-theme.git' does not existfatal: clone of '/opt/build/DanFerestre.com-theme.git' into submodule path '/opt/build/repo/themes/icelab-hugo' failedFailed to clone 'themes/icelab-hugo' a second time, aborting
6:07:19 PM: Creating deploy upload records
6:07:19 PM: Failing build: Failed to prepare repo
6:07:19 PM: Failed during stage 'preparing repo': Error checking out submodules: warning: could not look up configuration 'remote.origin.url'. Assuming this repository is its own authoritative upstream.Submodule 'themes/icelab-hugo' (/opt/build/DanFerestre.com-theme.git) registered for path 'themes/icelab-hugo'fatal: repository '/opt/build/DanFerestre.com-theme.git' does not existfatal: clone of '/opt/build/DanFerestre.com-theme.git' into submodule path '/opt/build/repo/themes/icelab-hugo' failedFailed to clone 'themes/icelab-hugo'. Retry scheduledfatal: repository '/opt/build/DanFerestre.com-theme.git' does not existfatal: clone of '/opt/build/DanFerestre.com-theme.git' into submodule path '/opt/build/repo/themes/icelab-hugo' failedFailed to clone 'themes/icelab-hugo' a second time, aborting: exit status 1
6:07:19 PM: Finished processing build request in 2.429170065s

So I went again through the setup and it finally works now!

Maybe this here also helped: [Support Guide] How do I access private repositories in the build environment?

The only „feature request“ that I would make, is add support for relative submodule-paths. What do you think @coelmay ? (Where I can replace in .gitmodules https://GitHub.com/user/repo with …/repo)

1 Like

I figured out, that the submodule was only cached after switching back to https.

the only way for private submodules is ssh.

I therefore am switching to render.com. cya!

1 Like

Sorry to hear that you got stuck on this, but I appreciate you coming back and updating the thread during your debugging process!

Thank you too for your works here. I really loved working with Netlify. I will definitely check back again to see if you support private https submodules :slight_smile: :+1: