Moving from a master to a major version branch

Last updated on
17 September 2020

Although master branches are commonly used in the Git world, the Drupal community uses major version branches (e.g., 8.x-1.x ) and semantic versioning branches (e.g., 1.0.x) instead, since master could be compatible with Drupal 6, Drupal 7, Drupal 8/9, etc.

Some Drupal projects may have a master branch that contains code that should be in a major or semantic version branch. For example, old projects that were converted around 2011 from CVS repositories ended up with master branches. Also, some sandbox projects use a master branch, and then if they are later converted to full projects, they would need to convert that branch to a major or semantic version branch.

To convert an existing master branch to being a major or semantic version branch (1.0.x in this example), follow these steps:

  1. Make a new branch containing the code from the master branch:
    git checkout master
    git checkout -b 1.0.x
    git push origin 1.0.x
    
  2. If the project has a development release that uses the master branch, find this release either on the Project's main page or by clicking the View all releases link. Click the release title to go to the release page.
    title.png
  3. Click Edit.
    release_nodeedit.png
  4. Once on the page, select the new Git branch and save. Note that this field will only be editable if there is an appropriately named branch available that is not already associated with another release.release_node.png
  5. Return to the project page. Click Edit > Releases. Verify or update the supported and recommended branches for this project.
  6. Click Edit > Default branch. Verify or update the default branch for this project.
  7. Delete the master branch:
    git checkout 1.0.x
    git branch -D master
    git push origin :master
    

    Be sure you've set the appropriate default branch as directed above before you delete master entirely. Otherwise, you may get a "deleting the current branch is denied" Git error if master is still your default branch.

Tags

Help improve this page

Page status: No known problems

You can: