This post originally published on thoughtbot's Giant Robots blog.
Too often, I come across GitHub Pages branches (
gh-pages) branches that are
simply forks from the
master branch of the repository. This is not ideal.
There are several problems with this strategy:
- Unless you manually update the
gh-pagesbranch every time you add a commit to master, you will be out of date.
- It makes for a much more difficult to understand source folder for the Jekyll or HTML site, since people have to mentally categorize every file and folder into either “part of the site” or “an artifact from the master branch”.
It introduces the need to have lines like this in
_config.ymlto prevent unrelated files from being included in the
exclude: ./app, ./lib, ./project.gemspec, ./Gemfile, ./LICENSE, ./Rakefile, ./readme.md, ./features, ./spec
git checkout --orphan gh-pages
When it comes time to create a GitHub Page for your project, use the above
command. This creates a branch that is completely separate from the history of
the rest of the repository. You will need to delete the files by running
git rm -rf .
After you have an empty branch, you’re ready to get started on your Jekyll or HTML site with a clean history and a clear conscience.