Main menu

Quick tips: Adding an empty master branch

21 February 2012

When I create a git repository for a new project on Drupal.org I don't bother to create a master branch, branches named 6.x-1.x or 7.x-1.x have special meanings and are the ones that we're encouraged to use. However, drupal.org doesn't allow us to change the default branch on d.o itself, so even though there may be no branch called 'master', it's still the default branch, so sometimes cloning a repo will fail:

Which is what drupal.org will tell people to do on the version control tab.

The real fix

The correct way to get this fixed would be to get this issue about setting a default branch committed and deployed to Drupal.org. But, who knows when that will happen?

A workaround

As an interim workaround that will mean that people cloning your repo don't get an error if they don't specify a branch you can create and push a master branch to the repo.

The best way to do this is to follow the instructions below which basically creates an entire new git tree to work in and pushes that into the master branch. This means that your actual branches and the master branch share no commits at all.

Get yourself a nice clean checkout of your repo, and make sure you really don't have a master branch (if you do you don't need to follow these instructions anyway!)

About the author

Steven has a wealth of experience building Drupal-based websites and tools associated with them. He is a maintainer of the Aegir project and has contributed to many other projects on Drupal.org. He is currently our infrastructure lead and is a lead architect on many of our projects.

He is a Master of Mathematics graduate from the University of Warwick and got involved in Drupal creating a website for the Maths society there.