How to add submodule into gh-pages branch & build static pages correctly?

穿精又带淫゛_ 提交于 2019-12-03 05:51:06

I've got the answer from the Github (thanks @Robert).

Using submodules with Pages

If your repository contains submodules, they will automatically be pulled in when the Page is built.

Make sure you use the https:// read-only URL for your submodules, including nested submodules. You can make this change in your .gitmodules file.

Submodules must also be served from public repositories, as the Pages server cannot access private repositories.

So, I need to use

https://github.com/Kjuly/KYProjectPageTheme.git (new page recommends to use "https://")
git://github.com/Kjuly/KYProjectPageTheme.git (old page recommends to use "git://")

instead of

git@github.com:Kjuly/KYProjectPageTheme.git

And it works perfect now!!


Note, Old page said:

HTTPS and SSH URLs will cause the build to fail with a "submodule fetch failed" error.

Not sure whether the HTTPS one works or not now, but if the https:// not works for you, just keep using git:// instead.

I frequently run into this when I use SSH for my main repository and HTTPS for my sub-repository (prototyping framework).

I never tracked down exactly why this happens. I even contacted GitHub staff once, and they had to fix something in my repository.

It turns out there's an easier way: Use HTTPS for the parent repository and all subrepositories. This seems to work without any other tweaking.

I was generating a static website with Hugo, and had to format my .gitmodules file like so:

[submodule "themes/code-editor"]
    path = themes/code-editor
    url = https://github.com/aubm/hugo-code-editor-theme.git
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!