Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the main branch to master on github command line?

Tags:

git

github

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?

like image 225
Mostafa Yasser Avatar asked Sep 03 '25 04:09

Mostafa Yasser


1 Answers

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
like image 54
Jacob Lee Avatar answered Sep 04 '25 19:09

Jacob Lee