独书先生 Menu

提交main主分支后接着提交gh-pages分支

需求

我们在github建立的项目,有时候需要发布GitHub pages,有两种方案,1是源码一个仓库,打包后代码放到另一个仓库的gh-pages分支,2是源码一个仓库main分支,打包后代码还是放在本仓库的gh-pages分支。我们这里采用第二种方式

步骤

我们以线上开源项目vuepress-template为例,这一个vuepress 模板项目,打包后生成的dist文件夹在docs/.vuepress文件夹目录下

第一步:打包文件

npm run docs:build

第二步:dist提交git

git add docs/.vuepress/dist
git commit -m "Initial dist subtree commit"

第三步:push dist

git subtree push --prefix docs/.vuepress/dist origin gh-pages