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
?
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“.
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.
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)
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.
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
.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With