19

the image shows what it actually looks on command line

I'm learning to use GitHub, I found that my default branch is main although I've changed it to master using my account in GitHub website but it still appears on the command line as main. It has caused many problems in the authentication process in every git push command, I want to change the main branch to be (master => origin) like usual. Can anyone help me?

1
  • Not only do you have to change the name of the branch in your remote, but you'll have to change it locally as well: git branch -m master. Then, you'll need to set origin/master as the corresponding remote branch: git push -u origin master.
    – Jacob Lee
    Apr 29, 2021 at 1:17

2 Answers 2

26

So far, you have only renamed your remote branch from main to master. So, to change your local branch name, first, checkout branch main (if you aren't already on it):

$ git checkout main

Next, rename branch main to branch master:

$ git branch -m master

Then, set origin/master to track your local branch master:

$ git push -u origin master
1
  • Thanks, I really appreciate your answer. Apr 29, 2021 at 22:39
-6

the command is: git branch -m main master. this is also a link to understand it more: https://stevenmortimer.com/5-steps-to-change-github-default-branch-from-master-to-main/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.