Creating an Empty git branch

October 24, 2014

Today I needed to create an empty gh-pages branch on one of my projects, and didn't want to fork the code on the master branch, then remove it all.

There are plenty of solutions floating around online. Perhaps the most intriguing option plays with git's empty tree commit hash, i.e. the commit hash you get when you begin with an empty repository.

The easiest way I found, however, is branching from your current branch to a new "orphan" branch:

git clone --orphan gh-pages

This won't remove any files in your current working directory (though, all of them will be "new" to this branch). Remove them by resetting the working directory after you check you're truly on the right branch:

git branch  # Better safe than sorry
git reset --hard

Easy.

Was this helpful? Buy me a coffee with Bitcoin! (What is this?)

Updating Adobe Flash Without Restarting Firefox

No reason for a Flash upgrade to shut down your entire browser, even if it claims so.It's 2015, and the love-hate relationship of the Web...… Continue reading

Reddit's Fail-Alien (or "Fail-ien?")

Published on January 15, 2015