Git – create empty branch

Git represents branches as pointers to the latest commit in that branch. If you haven’t created a commit yet, there’s nothing for that branch to point to. So you can’t really create branches until you have at least one commit.

Git allows to create a empty branch but its not common way of using Git.

First create create an empty Git repository by using following command:

$ git init

To create empty branch use following command:

$ git commit --allow-empty -m "initial commit for empty brach"

After running above command it will create a master branch, run following command to conform:

$ git branch


* master

By Sandeep Posted in Git Tagged

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s