Notes on Life, ‘Puters and Hawaii

Creating Blank Git Branches

Most of the time in git you will be creating branches of your main project and working on them. What if you wanted to create a ‘documentation’ branch or something? It doesn’t really deserve it’s own repository because it’s so closely related. The git project repository does this. The git project repository has separate branches for master, docs and man pages etc too. Here’s how you do it.

Go into your git project and type

git symbolic-ref HEAD refs/heads/empty
git rm -rf *
echo 'New blank branch' >README
git add README
git commit -m 'New blank branch'

That’s it - now you have a new branch ‘empty’.

Comments are closed.