-2

I worked on php Project and i want to upload into "github" I am new in Github, I want to know that what is difference between "git push origin master" and "git push origin main" ?

Thank you in advance.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Johneisha
  • 15
  • 2

4 Answers4

2

git push origin master is pushing the code to the master branch. git push origin main is pushing the code to the main branch.

2

Origin and Master are two different terminologies used when working and managing the git projects.

Origin is the name used for the remote repository.

Master / Main is the name of the branch.

Sukma Dewa
  • 21
  • 3
1

Both are the names of branches on a repository on Git.

The master branch is the main branch on the code repository and now it is famous as the Main branch in Git.

So when you add changes to your repository You can use git push origin master or git push origin main in your repository.

If suppose you have name dev as branch name then you need to use that name like :

git push origin dev
NIKUNJ PATEL
  • 2,034
  • 1
  • 7
  • 22
0

Like others have answered before: main or master is just name of a branch. It can have an arbitrary name and which one is to be considered the "main" branch is up to convention.

Earlier versions of git used master so a lot of older repositories use this name. In recent times, main is favored.

It's really up to the individual project which branch to use.

There are also political issues involved. From a practical point of view, main is shorter by two letters so it saves some typing.

Friedrich
  • 2,011
  • 2
  • 17
  • 19