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

Dok*_*sky 6 javascript github github-api github-pages

有没有办法通过api启用Github页面?不是请求页面构建,我的意思是最初启用该功能并指向一个分支。

Bor*_*ian 4

您只需将内容推送到远程 git 存储库即可。
您必须区分用户页面(username.github.io)和项目页面(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
Run Code Online (Sandbox Code Playgroud)

项目页面:

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
Run Code Online (Sandbox Code Playgroud)