Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference Between Main Branch and Master Branch in Github?

Tags:

git

github

I tried git push on my master branch, but it just shows that I have a new pull request. When I click on the new pull request, it takes me to the comparing changes view, but doesn't show any option to add those changes into repository. It only shows the changes I made:

Screenshot of different branches

Screenshot of the GitHub Compare Changes view showing no changes

When I entered the command

git push origin main

all files where added to my repository.

but when I do

git push origin master

it doesn't work. Why is that? I heard they are replacing master with main. So in the future are they going to remove master?

like image 925
Prathu9 Avatar asked Oct 07 '20 17:10

Prathu9


3 Answers

From the ZDNet article, GitHub to replace "master" with alternative term to avoid slavery references:

GitHub is working on replacing the term "master" on its service with a neutral term like "main" to avoid any unnecessary references to slavery,

About renaming your branch from master to main, there are a lot of guidelines. For example:

git branch -m master main \
git push -u origin main \
git remote set-head origin main
like image 199
minion Avatar answered Oct 27 '22 13:10

minion


They just changed the default branch for new repositories. You can also set it back to master here -> https://github.com/settings/repositories

like image 33
Unglückspilz Avatar answered Oct 27 '22 14:10

Unglückspilz


The main branch has already replaced all new github repos as the main branch. You can read up on it here. There is no actual difference between main and master, it's just the name of the default branch.

For you git push origin master just creates a new branch called master (since it doesn't exist already) and pushes your current commits there.

like image 21
tistorm Avatar answered Oct 27 '22 14:10

tistorm