01 Jan 0001 -  Giulio Vian -  ~2 Minutes

Changing the default branch for existing repositories

Given the current state of tools, it is not recommended to change the default branch. You should weight the effort and consequences as it may be sizeable effort. The required tasks to implement the change are grouped by tool impacted.

Azure DevOps Repos

1. Set the new default branch in Azure DevOps.
2. Recreate the branch policies on the new branch.
3. Redirect any open Pull Request to the new branch.
4. Check if there are Web Hooks associated with the on Git repo using a branch filter.
5. Check if there are Forks of the source Repo and update them.

Client tools (Visual Studio, Visual Studio Code, Eclipse, IntelliJ IDEA, etc.)

1. Update all clones to use the new branch, `git fetch` followed by `git remote set-head origin -a`.
2. Check any local Git work-tree.

Azure DevOps Pipelines

1. Update Azure DevOps Build Triggers associated with the Repository, note that triggers declared in YAML can be overridden in the Build definition.
2. Reconfigure the default checkout branch in Classic Editor.
3. Check the YAML file or in the Classic Editor for references to `master` in:
	1. tasks and/or steps conditions;
	2. expression that calculate version numbers;
	3. log messages;
	4. notification messages.
4. Check the Values of Build variables.
5. Check that required Extensions still work with the new default (Extensions may hardcode the string `master`, e.g. GitVersion).
6. Build statistics will be split between the new and old default branch for some time.
7. SonarQube data will be split between the new and old default branch for some time.
8. Check that Build notifications are associated with the new branch.
9. A Build Status badge embeds the branch name, they must be updated.
See also this blog post https://jessehouwing.net/git-rename-your-master-branch-to-something-better/.


There might be additional references to master in other places. We suggest to check:

  • Azure Boards automations
  • Team Documentation

comments powered by Disqus