Skip to content

Instantly share code, notes, and snippets.

@francisrupert
Created April 5, 2016 14:55
Show Gist options
  • Save francisrupert/3f592bbed4d0c6b7c451451be1ad8d1a to your computer and use it in GitHub Desktop.
Save francisrupert/3f592bbed4d0c6b7c451451be1ad8d1a to your computer and use it in GitHub Desktop.
Switching Your GitHub Repo To Use Only The gh-pages Branch

Copied from http://www.xanthir.com/b4Zz0

(This is a simplified version of the advice on Oli Studholme's blog, cut down to just the parts that I've actually needed. I do this often enough, and always forget the steps, so having it put down here is useful for me, and maybe for someone else.)

So you want to serve your repo from the http://user.github.io/repo url, and don't have any reason to separate a "code" and "serve" branch. In other words, you want your GitHub repo to only use the gh-pages branch, not master. Here's an easy guide to making that happen.

First, if you already have a gh-pages branch, make sure it's synced up to master, showing exactly what you want. If you don't, type...

git checkout -b gh-pages
git push origin gh-pages

Second, go to GitHub, settings for your repo, and switch “Default Branch” to gh-pages, (or perhaps gh-pages-staging)

Third, delete the local master branch with...

git branch -d master.

Finally, delete the remote master branch with...

git push origin :master

Done. You now have only the gh-pages branch, and it's the default one that git will use when talking with GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment