Gist Overview: Publish React build files to Github Pages using a branch (2025)
For New Projects
- Create a new branch from master
git checkout -b public - Remove
distfrom.gitignore - Add your github base url (eg.
myusername.github.io) to build configs. - Build project, then add/commit files.
- Push the built directory to the remote
publicbranch:
git subtree push --prefix dist origin public
To Make Updates
- Checkout the public branch and merge with master.
- Build project, then add/commit files.
- Push the updates again with:
git subtree push --prefix dist origin public
Setup Github
- Set Project's Github Page to use the
publicbranch