

Verify on page refresh that your "main" branch is listed properly as "protected".In the same repository settings page as above, in the "Protected Branches" section, fill out the form to protect your new "main" branch, and click the green "Protect" button.Expand the "Protected Branches" section, and select "Unprotect" on the 'master' branch.In the left-side navigation, under "Settings", select "Repository".Log into U-M GitLab, and select the repository you'd like to change.You'll need to resolve this before you can go on. Additionally, your old "master" might be set as "protected". ! master (refusing to delete the current branch: refs/heads/master)Įrror: failed to push some refs to GitLab, like other code-hosting platforms, automatically defines a "default" branch, and deleting this branch is not allowed. In many cases, however, you will see an error message like the following one: To Let's go on and remove the old "master" branch on the remote: $ git push origin -delete masterĭepending on your exact setup, this might have worked and the renaming is successful. We now have a new branch on the remote named "main". Make sure your current local HEAD branch is still "main" when executing the following command: $ git push -u origin main Instead, we'll have to create a new "main" branch and then delete the old "master" branch. In this second step, we'll have to create a new branch on the remote named "main" - because Git does not allow one to simply "rename" a remote branch. Renaming the Remote "master" Branch in U-M GitLab The local branch has been renamed - but we now need to make some changes in the remote repository in U-M GitLab as well. Your branch is up to date with 'origin/master'. Then, check to see if the rename has worked as expected: $ git status The first step is to rename the "master" branch in your local Git repository: $ git branch -m master main How do I rename the "master" Branch in a Git Repository? Resolution Renaming the Local "master" Branch
