以编程方式为存储库启用 Github 页面

Programmatically enable Github Pages for a repository

有什么方法可以通过 api 启用 Github 页面吗? 不请求页面构建,我的意思是初始启用该功能并指向一个分支。

您只需将内容推送到远程 git 存储库。
您必须区分 User-Page (username.github.io) 和 Project-Page (username.github.io/projectname)

用户页面:

git clone https://github.com/username/username.github.io
cd username.github.io

echo "Hello World" > index.html

git add --all
git commit -m "Initial commit"
git push -u origin master

项目页面:

git clone https://github.com/user/repository.git
cd repository

git branch gh-pages
git checkout gh-pages
echo "Hello World" > index.html

git add --all
git commit -m "Initial commit"
git push -u origin gh-pages