Difference Between Main Branch and Master Branch in Github?
I tried git push on master branch but it just shows that I have new pull request but when I click on new pull request it takes me to comparing changes but doesn't show any option to add those changes into repository. It only shows changes I made.
But when I entered 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 it? I heard they are replacing master with main. So in future are they going to remove master?
GitHub is working on replacing the term "master" on its service with a neutral term like "main" to avoid any unnecessary references to slavery,
You can read here for more background the reason for the change here:
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
They just changed the default branch for new repositories. You can also set it back to master
here -> https://github.com/settings/repositories
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.
You can follow these instructions:
At first create a repo at GitHub. Then go into your local folder. Open a console. Enter these commands one after the other.
git init
Initialises git in your local folder.
git remote add origin https://github.com/...
Clone your Github repo.
git pull origin main
Calibrate repos. The "main" means that in this case the content of the main branch is copied to the local repo. Other branches can be created in addition to the master branch, but I will not go into this in detail. For the beginning, it is sufficient to have a simple master branch.
git branch -m master main
So what are we doing here? First with the -m command we are moving the git history from master to a new branch called main.
git add .
The locale directory is uploaded to the Github server.
git commit -m "your commit message"
git push --set-upstream origin main
After the commit has been created, the remote repo can be updated on GitHub. When uploading for the first time ("push"), you have to specify which branch should be the default for pushes. In our case, this should again be the master branch in the "origin" repo
GitHub is working on replacing the term "master" on its service with a neutral term like "main" to avoid any unnecessary references to slavery, its CEO said on Friday.
Now commands look likes this:
git push -u origin main
git remote set-head origin main
It’s not updated in Enterprise yet but it already reflected in the community edition.
Update: You can change back main
to master
from repository settings.