Page MenuHomeClusterLabs Projects

How To Rename Git Default Branch
Updated 163 Days AgoPublic

Most of the ClusterLabs projects' git repositories renamed their default branch to main in late December 2021.

Anyone who has an existing fork and/or checkout of an affected repository will have a dangling reference to the old name. This document describes how to fix those.

Rename default branch in a fork

If you have a Github fork of a project whose default branch was renamed, go to the github page for your fork, select Settings then Branches, and rename the default branch to main. Then do this from one checkout of your fork:

git checkout master
git branch -m master main
git push -u origin main
git remote set-head origin -a

If you have more than one checkout of your fork, run everything above except the push in each of the others.

Rename default branch in a checkout

If you only have checkouts (not a fork) of the upstream repository, update each one like this:

git checkout master
git fetch --all
git remote set-head origin -a
git branch --set-upstream-to origin/main
git branch -m master main
Last Author
kgaillot
Last Edited
Jan 4 2024, 1:28 PM