Skip to content

Renaming the default branch in Azure Data Factory Git repositories from "master" to "main"

Branch icon.

In Azure Data Factory, you can connect to a Git repository using either GitHub or Azure DevOps. When connecting, you have to specify which collaboration branch to use. In most cases, the default branch is used. Historically, the default branch name in git repositories has been “master”. This is problematic because it is not inclusive and is very offensive to many people.

The Git project, GitHub, and Azure DevOps are making changes to allow users to specify a different default branch name. GitHub and Azure DevOps will be changing their default branch names to “main” in 2020. I fully support this change and will be doing the same in my projects.

In this post, we will go through how to rename the default branch from “master” to “main” in Azure Data Factory Git repositories hosted in GitHub and Azure DevOps. Then we will reconnect Azure Data Factory and configure it to use the new “main” branch as the collaboration branch.

For these examples, I’m using my personal demo projects. I’m not taking into consideration any branch policies, other users, third-party tools, or external dependencies. As always, keep in mind that this is most likely a larger change, both technically and organizationally, in production and enterprise projects. 😊

The Short Version

  1. Create a new “main” branch in your Git repository
  2. Set the new “main” branch as the default branch in your Git repository
  3. Delete the old “master” branch in your Git repository
  4. Disconnect from your Git repository in Azure Data Factory
  5. Reconnect to your Git repository in Azure Data Factory using the new “main” branch as the collaboration branch

For The Longer Version with Screenshots, scroll down to GitHub or Azure DevOps 👇🏻

GitHub

GitHub icon.

(If you are using Azure DevOps instead, scroll down 👇🏻🤓)

Open your Azure Data Factory Git repository in GitHub. On the Code page, click on the branch dropdown where it says “master”. Type “main” as the new branch name, then click on Create branch: main from master:

Screenshot of the Code page in GitHub with the new branch dropdown highlighted.

The new “main” branch is now selected. Click on branches to view all branches:

Screenshot of the Code page in GitHub with the branches link highlighted.

In the branches overview, click on Change default branch:

Screenshot of the branches overview page in GitHub with the change default branch button highlighted.

On the default branch page, click on the branch dropdown where it says “master”. Select “main”, then click on Update:

Screenshot of the default branch page in GitHub with the change default branch dropdown highlighted,

The warning says that changing your default branch can have unintended consequences that can affect new pull requests and clones. Click on I understand:

Screenshot of the update default branch warning text in GitHub with the I understand button highlighted.

Yay! The default branch has now been changed to “main”:

Screenshot of the default branch page in GitHub showing a notification that the default branch has been changed.

Back in the branches overview, click on the delete icon next to the “master” branch to delete it:

Screenshot of the branches overview page in GitHub with the delete button next to the master branch highlighted.

The “master” branch is now deleted:

Screenshot of the branches overview page in GitHub after the master branch has been deleted.

Open or switch back to your Azure Data Factory. If you get a notification that the current working branch was deleted, use the new “main” branch instead:

Screenshot of Azure Data Factory showing the “select working branch” settings with the new “main” branch highlighted.

Go to the Manage page and click on Git Configuration. Then click on Disconnect:

Screenshot of the Manage page in Azure Data Factory showing the Git Configuration settings with the Disconnect button highlighted.

You will see a warning that you should publish all pending changes before disconnecting to avoid losing any changes. I always recommend that you do this just in case, but since we will immediately reconnect to our Git repository, you don’t have to do it in this case. Type the name of your data factory and click on Confirm:

Screenshot of the confirmation and warning screen in Azure Data Factory when disconnecting from a Git Repository.

Now we can reconnect. Click on Set up code repository:

Screenshot of the Manage page in Azure Data Factory showing the Git Configuration settings with the Set up code repository button highlighted.

Select the new "main" branch as the collaboration branch and make sure you uncheck Import existing Data Factory resources to repository. This ensures that you keep what is in the “main” branch as-is. Then click on Apply:

Screenshot of the Git repository settings in Azure Data Factory with the collaboration branch and import settings highlighted.

That’s it! The new “main” branch is now the collaboration branch and has a star icon next to it in the branch dropdown:

Screenshot of the Manage page in Azure Data Factory showing the Git Configuration settings connected to the “main” branch.

Azure DevOps

Azure DevOps icon.

(If you are using GitHub instead, scroll up ☝🏻🤓)

Open your Azure Data Factory Git repository in Azure DevOps. On the Branches page, click on New branch:

Screenshot of the Branches page in Azure DevOps with the New branch button highlighted.

Type “main” as the new branch name, base it on “master”, then click on Create:

Screenshot of the Branches page in Azure DevOps with the Create a branch pane highlighted.

Click on the vertical ellipsis button next to the new “main” branch to open the “More…” menu, then click on Set as default branch:

Screenshot of the Branches page in Azure DevOps with the Set as default branch option highlighted.

Yay! The “main” branch is now showing as the new default branch:

Screenshot of the Branches page in Azure DevOps with the new “main” branch set as the default branch.

Click on the vertical ellipsis button next to the old “master” branch to open the “More…” menu, then click on Delete branch:

Screenshot of the Branches page in Azure DevOps with the Delete branch option highlighted

The “master” branch is now deleted:

Screenshot of the Branches page in Azure DevOps with only the adf_publish branch and main branch left.

Open or switch back to your Azure Data Factory. If you get a notification that the current working branch was deleted, use the new “main” branch instead:

Screenshot of Azure Data Factory showing the “select working branch” settings with the new “main” branch highlighted.

Go to the Manage page and click on Git Configuration. Then click on Disconnect:

Screenshot of the Manage page in Azure Data Factory showing the Git Configuration settings with the Disconnect button highlighted

You will see a warning that you should publish all pending changes before disconnecting to avoid losing any changes. I always recommend that you do this just in case, but since we will immediately reconnect to our Git repository, you don’t have to do it in this case. Type the name of your data factory and click on Confirm:

Screenshot of the Disassociate from repository pane in Azure Data Factory with the Confirm button highlighted.

Now we can reconnect. Click on Set up code repository:

Screenshot of the Manage page in Azure Data Factory showing the Git Configuration settings with the Set up code repository button highlighted.

Select the new "main" branch as the collaboration branch and make sure you uncheck Import existing Data Factory resources to repository. This ensures that you keep what is in the “main” branch as-is. Then click on Apply:

![ Screenshot of the Git repository settings in Azure Data Factory with the collaboration branch and import settings highlighted.}(/images/adf/renaming-default-branch/AzureDataFactoryRenameDefaultBranchADF10.png “border”)

That’s it! The new “main” branch is now the collaboration branch and has a star icon next to it in the branch dropdown:

Screenshot of the Manage page in Azure Data Factory showing the Git Configuration settings connected to the “main” branch.

Summary

In this post, we looked at how to rename the default branch in GitHub and Azure DevOps, and how to reconnect Azure Data Factory to use the new default branch as the collaboration branch:

  1. Create a new “main” branch in your Git repository
  2. Set the new “main” branch as the default branch in your Git repository
  3. Delete the old “master” branch in your Git repository
  4. Disconnect from your Git repository in Azure Data Factory
  5. Reconnect to your Git repository in Azure Data Factory using the new “main” branch as the collaboration branch

That’s it! 🤓

Share or Comment?

About the Author

Professional headshot of Cathrine Wilhelmsen.Cathrine Wilhelmsen is a Microsoft Data Platform MVP, international speaker, author, blogger, organizer, and chronic volunteer. She loves data and coding, as well as teaching and sharing knowledge - oh, and sci-fi, gaming, coffee and chocolate 🤓