Skip to content

Instantly share code, notes, and snippets.

@balain
Last active October 25, 2020 18:29
Show Gist options
  • Save balain/89d9806b5b84be6566122f09383b4d31 to your computer and use it in GitHub Desktop.
Save balain/89d9806b5b84be6566122f09383b4d31 to your computer and use it in GitHub Desktop.
Renaming master branch to main on github

Source: https://www.r-bloggers.com/2020/07/5-steps-to-change-github-default-branch-from-master-to-main/

Step 1

create main branch locally, taking the history from master

git branch -m master main

Step 2

push the new local main branch to the remote repo (GitHub)

git push -u origin main

Step 3

switch the current HEAD to the main branch

git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main

Step 4

change the default branch on GitHub to main

Step 5

delete the master branch on the remote

git push origin --delete master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment