Skip to content

Latest commit

 

History

History
133 lines (97 loc) · 5.09 KB

rename-master-to-main.md

File metadata and controls

133 lines (97 loc) · 5.09 KB
title description
Renaming master branches to main
a CLI to manage applications deployed to Kubernetes

Guide on how to rename master branches to 'main'

Starting with the easier repositories

A list of repositories that are not software services or not connected / automatically hooked with software services and therefor could easily be changing the main branch name to 'main':

A list of artsy gems and libraries that might be loaded into gemfiles with referring to the master branch.

Projects that use hokusai for automated deployments but not mission-critical to the Artsy ecosystem:

Check for open PRs on master

Make sure that after the renaming process the PRs are still open and now pointing to main.

Update CI and docs

Search the repository for any references to the old master branch name and update them to use main, especially:

  • Continuous integration steps configured in .circleci/config.yml
  • Any set-up instructions or scripts

Create a pull request with these changes (e.g.), and monitor that they build and deploy to staging successfully.

Renaming the Remote master Branch

Make sure you are on your local master branch and also pulled the latest changes.

Because on Github you probably configured the master branch as the default branch. To configure the main branch as default, go to the settings/branches and change the default branch to main.

screen shot branch settings

Now every team member needs to update their local default branch. This is what you can see on GitHub once the master branch is renamed. You can copy the commands from the section Team Duties after rename below. There are two options listed, a complicated and an easier way 😄. update local default branch

Team Duties after rename

The complicated way:

# Switch to the "master" branch:
$ git checkout master

# Rename it to "main":
$ git branch -m master main

# Get the latest commits (and branches!) from the remote:
$ git fetch origin

# Create a new tracking connection with the new "origin/main" branch:
$ git branch -u origin/main main

# Reset the remote head to main:
$ git remote set-head origin -a

The easy way:

# fetch main
$ git fetch origin main

# get the remote main branch and check it out locally
$ git checkout main

# delete local master branch
$ git branch -D master

Release Automation

If the project's release pipeline is automated with Horizon, edit the project's "stages":

  • Login to https://releases.artsy.net/admin/projects
  • Find the project in Horizon's project list, click "edit."
  • Click "stages" to list the stages and "edit" to edit the master branch.
  • Update the name and branch fields to be main as mentioned in the doc.
  • Click Update to save.

External tools

Since we haver external tools that are not possible to map by checking the repository code itself, this is something we need to consider as a Team duties after rename as well. Well known tools that are not easy to map:

  • Jenkins
  • Airflow