07 9 / 2011

Creating an empty Git branch on an existing repo

There might be situations where you have to create an empty git branch on an existing repo. I had done such thing couple of times before but every time I have to do it, I have to google it.

So documenting myself not to google from next time. The following process assumes that we’re going to create an empty branch named website. Replace it with your desired name.

cd my-git-repo

git symbolic-ref HEAD refs/heads/website

git rm --cached -r .

rm -Rf lib/ (remove other directories you don't want in this new branch)

git commit --allow-empty -m 'initial website branch'

Tags:

Permalink 3 notes