How To Change Master Branch To Main Branch Before Pushing Remotely To GitHub.

How To Change Master Branch To Main Branch Before Pushing Remotely To GitHub.

Photo by Zach Reiner on Unsplash

All new source code on GitHub is named "main" not "master" now. I had a local-only project that had a "master" branch on it:

master.png

I honestly don't remember how it happened, but irregardless, I wanted to change it to "main" BEFORE I did a remote push to GitHub. This way there are no conflicts/issues.

Here is how you do it:

Go in your terminal window and make sure you are in the right directory. It should say "master". And type "git branch -m master main":

one.png

That's it! Honestly!:

two.png

Type in "git status" to make sure. Make sure it says "On branch main":

three.png

The last step I did to connect my local main branch to a remote repo was to go on GitHub's site and create a repo. After creating the repo I copied the following code and pasted it into my terminal window:

four.png

Now the local main branch is connected or synced with the remote main branch. So you are good to go!