[dbt Cloud] How to rename your GitHub branch from master to main

In 2020, the git project and GitHub (along with other tools) announced plans to make it easier for repositories to move away from the harmful default branch name master.

dbt Cloud has always supported a custom branch name in development, but I was slow to make the change in our project because I thought it was going to be a big hassle. It was not a big hassle at all! This post is a PSA for anyone else who has been procrastinating the change.

Updating your branch only takes a couple of minutes, and consists of three (± one) simple steps:

  1. Rename your branch in GitHub (if necessary)
  2. Update the branch settings in your Environments
  3. Refresh your IDE
  4. Update your local git clone (if necessary)

1. Rename your branch in GitHub

:information_source: If you’re setting up your dbt repo for the first time, this is probably redundant - your branch will likely already be called main.

The instructions on the GitHub help site are pretty comprehensive, but in short: go to the list of branches and click the :pencil2: icon.

2. Update the branch settings in your Environments

  1. Click the hamburger icon in the top left of the dbt Cloud interface, and go to Environments.

  2. Click into your Development environment:

  3. Tick the Custom Branch tickbox, type in the same name as your GitHub branch, then hit Save.

  4. Repeat for the Production environment, as well as any other Environments you have.

3. Refresh your IDE

The next time you or your colleagues open the IDE, you might see this warning message:


Make sure you have your work saved, then click Refresh IDE.

:safety_vest::rescue_worker_helmet: It should be OK to have code which is saved but not committed when you refresh the IDE. However, out of an abundance of paranoia I made sure no one was in the IDE and that everyone’s code was already committed when we made this change.

4. Update your local copy of your code (if you have one)

If you’ve cloned your repo to your computer, GitHub won’t automatically fix that for you. You’ll need to follow the directions on their help site to manually resolve the rename.

That’s it!

Pat yourself on the back - everything will keep working exactly as it did before. If I’ve missed anything, please share it below.

3 Likes

Good article

Hopefully dbt will start to have main as the default soon :slightly_smiling_face: