Moving from a master to a major version branch
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:
- 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
- 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.
- Click Edit.
- 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.
- Return to the project page. Click Edit > Releases. Verify or update the supported and recommended branches for this project.
- Click Edit > Default branch. Verify or update the default branch for this project.
- 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.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion