一、使用gh-pages分支
新建gh-pages分支
先clone仓库,就不多说了。
为了与其它分支互不影响,我们要新建一个“孤立”的gh-pages分支。
git checkout --orphan gh-pages
删除新的gh-pages分支中的一切文件:
git rm -rf .
或
git rm -rf *
新建index.html:
echo "" > index.html
提交更改:
git commit -m "Create index.html"
推送gh-pages分支到服务器:
git push origin gh-pages
修改 GitHub Pages 源
- 打开仓库的Settings:1

- 找到
GitHub Pages一栏,将Source从None改为gh-pages branch:

- 然后
Save:

现在,我们修改index.html以及其它gh-pages分支中的文件。访问https://<username>.github.io/<repository name>/就可以看见gh-pages分支中的网页。
二、使用master分支中的/docs目录
新建
在master分支中新建/docs目录。
修改 GitHub Pages 源
- 打开仓库的Settings:2

- 找到
GitHub Pages一栏,将Source从None改为gh-pages branch:

- 然后
Save:

现在,我们修改index.html以及其它/docs中的文件。访问https://<username>.github.io/<repository name>/就可以看见/docs中的一切文件(包括网页)。
1200

被折叠的 条评论
为什么被折叠?



