Gangmax Blog

Git: Change Default Branch from "master" to "main"

First, you need to create the “main” branch as normal branch, and push it to remote.

In GitHub(the remote side), go the “Settings” of the repository, set the “main” branch as “Default branch”. Then open “View all branches” page of the repo, remove the “master” branch.

In local side, you need to following the instructions below(from here), to avoid the “Your configuration specifies to merge with the from the remote, but no such ref was fetched” error when running “git pull”.

1
2
3
git checkout main
git branch --unset-upstream
git branch --set-upstream-to=origin/main

Now you can run “git pull” without issue.

Comments