-
Create the
gh-pages
branch and initialize it with nothing except a.gitkeep
file. -
Add
gh-pages/
folder in.gitignore
to keep git history clean. -
From the
master
branch, clone thegh-pages
branch into thegh-pages
folder:
$ git clone <repo> --branch gh-pages gh-pages
- Create a deploy script in
package.json
.
For instance for a little project of mine using the angular CLI:
"deploy": "rm -f gh-pages/* && ng build --base-href 'https://USERNAME.github.io/PROJECT/' && cp dist/* gh-pages/ && cd gh-pages && git add --all && git commit -m \"Release at $(date)\" && git push"
That's all.
More ideas here.