Skip to content

Instantly share code, notes, and snippets.

@valera-rozuvan
Last active February 9, 2022 01:14
Show Gist options
  • Save valera-rozuvan/c2469c698c00649ccaac52204e75edab to your computer and use it in GitHub Desktop.
Save valera-rozuvan/c2469c698c00649ccaac52204e75edab to your computer and use it in GitHub Desktop.
howto switch from master to main branch

howto switch from master to main branch

  1. Create a new branch locally from current master - call it main:
git checkout -b main
  1. Push the new branch to GitHub:
git push --force origin main
  1. Go to GitHub project, go to settings, go to branches, switch default branch to main.

  2. Locally, do the following:

git fetch origin
git branch -u origin/main main
git remote set-head origin -a
  1. Now you are ready to delete the local master, and the remote master:
git branch -D master
git push origin --delete master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment