Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.