Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guidance on main and master branch in github

Tags:

git

github

I had created a remote repository in Github and pushed my project into that remote repository. After pushing it, a new branch is created master and now I have two branches main and master. The default branch is main which shouldn't be. At the time of the creation of the remote repository, I have added a Readme.md file maybe because of that main branch is created in the first place. Could you correct me here?

As of now, I have two branches, and I changed the default branch to master. For the main branch, it is showing as main had recent pushes 43 minutes ago and compare & pull request button. When I clicked the button it is showing as below.

When the main branch is created, Is it because of adding Readme.md file? How can I do a pull request as I am developing a small project alone? Need some guidance on that. enter image description here

like image 637
Subrato Pattanaik Avatar asked Oct 12 '20 13:10

Subrato Pattanaik


People also ask

What is master and main branch in GitHub?

The master branch is no different than any other branch in a cloned Git repo, except that historically it's been the default name used when the first branch is created. A developer can delete, rename and even re-create the master branch after it's deleted, just like any other Git branch.

What is the difference between master and main in GitHub?

Each repository can have one or more branches. The main branch — the one where all changes eventually get merged back into, and is called master. This is the official working version of your project, and the one you see when you visit the project repository at github.com/yourname/projectname.

Does GitHub use Main instead of master?

GitHub is gradually renaming the default branch of our own repositories from master to main . We're committed to making the renaming process as seamless as possible for project maintainers and all of their contributors. This repository is our up-to-date guidance on how and when to rename your default branch.


Video Answer


1 Answers

Recently, GitHub has decided to change the default branch upon creating a new repo to main.

If you don't have any commits in main and you don`t need it, just delete that branch.

The screenshot you posted shows that there isn't anything to compare between the two branches and since you already made master the default, instead of main, you then don't really need main.

If you need to delete main there are many ways, either through the GitHub UI or command line (related).

Edit

GitHub now provides a setting that allows you to change the name of the default branch to every repository through https://github.com/settings/repositories. Here you can revert back to "master" as your default branch name.

like image 67
mnestorov Avatar answered Oct 06 '22 00:10

mnestorov