Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

git - Guidance on main and master branch in 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...