Published : 2015-07-16

Create an empty branch

In some cases it can be useful to create a new branch containing no file, for instance for environment-specific contents.

Git allows to create branches without any parent, those are orphan branches. To create an orphan branch, just pass the orphan argument to checkout.

git checkout --orphan BRANCHNAME

The orphan will however have prepared the source branch files ready to be committed. Simply remove them with the following git command:

git rm -rf .