Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between git push origin and git push origin master

Is there any difference in pushing the master branch of a local git repository to the master branch of a remote repository called origin with git push origin master or with git push origin?

like image 593
Hilbert- Avatar asked Sep 17 '12 15:09

Hilbert-


People also ask

What is origin in git push origin master?

Origin is simply the name given to any remote repository available on GitHub. Whenever we need to push the changes to a remote repository, we use git push along with the remote repository “origin” and “master” branches. The term used is “git push origin master“.

What is the difference between origin and master in git?

The term "git origin master" is used in the context of a remote repository. It is used to deal with the remote repository. The term origin comes from where repository original situated and master stands for the main branch. Let's understand both of these terms in detail.

Is Origin and master the same?

origin/master is an entity (since it is not a physical branch) representing the state of the master branch on the remote origin . origin master is the branch master on the remote origin . So we have these: origin/master ( A representation or a pointer to the remote branch)

What is git push origin in git?

In simple words git push command updates the remote repository with local commits. The origin represents a remote name where the user wants to push the changes. git push command push commits made on a local branch to a remote repository.


2 Answers

The default action of git push and git push origin has changed since git version 1.7.11:

  • Before 1.7.11, git push by default pushes all branches that also exist remotely with the same name.

  • Since 1.7.11, git push by default pushes the current branch to a remote branch with the same name.

Before and after version 1.7.11, the default behavior can be configured with the push.default configuration option. This configuration option has been introduced in git version 1.6.3.

like image 160
ouah Avatar answered Oct 08 '22 03:10

ouah


git push origin master 

This only pushes your master branch to origin

git push origin 

Pushes all your branches to origin

UPDATE - The behavior of Git has changed since this answer was written. git push origin on Git >=2.0 by default pushes the current branch to a matching branch of the same name, but this behavior can be overridden via git config

like image 44
bluesman Avatar answered Oct 08 '22 04:10

bluesman