Nepal on Rails

millisami's rants!

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 dont want in this new branch)

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