Skip to content

Instantly share code, notes, and snippets.

@iamjohnmills
Last active May 3, 2025 23:11
Show Gist options
  • Save iamjohnmills/77fd0507678f8be6d9e07213a937cd2b to your computer and use it in GitHub Desktop.
Save iamjohnmills/77fd0507678f8be6d9e07213a937cd2b to your computer and use it in GitHub Desktop.

Gist Overview: Publish React build files to Github Pages using a branch (2025)


For New Projects

  1. Create a new branch from master git checkout -b public
  2. Remove dist from .gitignore
  3. Add your github base url (eg. myusername.github.io) to build configs.
  4. Build project, then add/commit files.
  5. Push the built directory to the remote public branch:
    git subtree push --prefix dist origin public

To Make Updates

  1. Checkout the public branch and merge with master.
  2. Build project, then add/commit files.
  3. Push the updates again with:
    git subtree push --prefix dist origin public

Setup Github

  1. Set Project's Github Page to use the public branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment