Updating...
Skip to main content
Filter your search by category. Current category:
All
All
Knowledge Base
Service Catalog
Search the client portal
Search
Sign In
Show Applications Menu
ITC Services Portal
Sign In
Search
Home
Faculty
Students
Careers
Feedback
Services
Knowledge Base
More Applications
Skip to Knowledge Base content
Search
Articles
Blank
Knowledge Base
Administrative and Reporting Systems
Application Support and Maintenance Procedures
Code Repository Support and Maintenance
GitLab rename master branch to main
GitLab rename master branch to main
Tags
programming
Code
git
scm
version-control
The following steps show how to rename the
master
branch to
main
in GitLab.
Create the repository in GitLab as you normally would
On your laptop, clone the repository locally
git clone git@git.dartmouth.edu:netid/myapp.git
If the repository is empty, add a README.md file because the next steps will not work on an empty repository
cd myapp
touch README.md
git add -A
git commit -m 'Initial commit'
git push
Create main branch locally and then push it to the remote
git branch -m master main
git push -u origin main
In GitLab, remove protection from
master
and add it to
main
Browse to
https://git.dartmouth.edu/netid/my-app
Click "Settings", then "Repository"
Next to "Protected Branches", click "Expand"
In the list of branches, click "Unprotect" on the "master" branch
Click "OK" to confirm
On the "Protect a branch" section, choose:
Branch: main
Allowed to merge: Maintainers
Allowed to push: Maintainers
Click "Protect"
In GitLab, change the default branch to
main
Still in the Repository Settings, next to "Default Branch", click "Expand"
Set "Default Branch" to "main"
Click "Save changes"
Delete the
master
branch
git push origin --delete master
If there are other clones of the repo (perhaps by team members), those can be updated with the following steps
cd path/to/repos/myapp
git checkout master
git branch -m master main
git fetch
git branch --unset-upstream
git branch -u origin/main
Sign in to leave feedback
100% helpful - 1 review
Blank
Blank
Blank
Details
Article ID:
130751
Created
Sat 3/20/21 2:10 PM
Modified
Sat 3/20/21 2:13 PM
Deleting...
×
Share
Recipient(s)
- separate email addresses with a comma
Message
Press Alt + 0 within the editor to access accessibility instructions, or press Alt + F10 to access the menu.
Check out this article I found in the ITC Services Portal knowledge base.<br /><br /><a href="https://services.dartmouth.edu/TDClient/1806/Portal/KB/ArticleDet?ID=130751">https://services.dartmouth.edu/TDClient/1806/Portal/KB/ArticleDet?ID=130751</a><br /><br />GitLab rename master branch to main