Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 710 Bytes

rename-master-branch-to-main.adoc

File metadata and controls

34 lines (26 loc) · 710 Bytes

Rename master branch to main

Note
This can be applied to rename any branch

First rename the local master branch into main:

git branch -m master main

As branch is renamed, it is assumed only the master branch exists in the remote repository.

Push the new branch:

git push -u origin main

Change the default branch of the project to main (if not done yet when repository has been created).

If needed, delete the remote master branch:

git push origin --delete master

Using prezto aliases:

# Rename local branch
gbm master main
# Push the new branch
gco main
gpc
# Delete the old branch (once no more the default branch)
gp origin --delete master