Skip to content

Instantly share code, notes, and snippets.

@xiaohk
Last active February 25, 2023 08:13
Show Gist options
  • Save xiaohk/bc1adfa16a1d274d62a999b62e26e88f to your computer and use it in GitHub Desktop.
Save xiaohk/bc1adfa16a1d274d62a999b62e26e88f to your computer and use it in GitHub Desktop.
Deploy to gh-pages

References

  1. Using git worktree for deploying to GitHub Pages
  2. Stackovervloew answer
## Setup

$ rm -rf dist
$ echo "dist/" >> .gitignore
$ git checkout -b gh-pages
$ git checkout main
$ git worktree add dist gh-pages # Make sure dist does not exist yet

## Making changes

$ cd dist
$ rm -rf * # Remove all initial files, this command would not delete hidden files
$ make # or what ever you run to populate dist
$ git add --all
$ git commit -m "Deploy $(git log '--format=format:%H' main -1)"
$ git push origin gh-pages
$ cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment