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

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

问题描述:

是否可以通过api启用Github页面? 不要求建立页面,是指最初启用该功能并指向分支.

Is there any way to enable Github pages through the api? Not requesting a page build, I mean the initial enabling of the feature and pointing to a branch.

您只需要将内容推送到远程git存储库即可.
您必须区分用户页面(username.github.io)和 Project-Page (username.github.io/projectname)

You just have to push content to the remote git repository.
You have to differentiate between a User-Page (username.github.io) and a 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