Git origin master - What is the difference between origin/master vs origin master in Git?

1.2K    Asked by LeahHarris in Devops , Asked on Jul 1, 2021

I know, the origin is a term for the remote repository and master is the branch there.

I am purposely omitting the "context" here and I am hoping that the answer should not depend upon the context. So in git command lines, What is git origin master? And what is the difference between origin/master and origin master? Is there a non-ambiguous way to understand when to use origin/master and when I should use origin master? 

Answered by jay Trivedi

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 the repository original situated and master stands for the main branch. Let's understand both of these terms in detail.

But here we need to see the difference between the three

    Origin, Master, origin/master

Origin: This is the name of a remote. A remote in Git is a common repository that all team members use to exchange their changes. In most cases, this will be an origin.

Master: This is a branch name where we first initiate git and then we use to make commits.

And the changes in the master can pull/push into a remote.

origin/master: This is a remote branch, which has a local branch named master on a remote named origin.



Your Answer

Interviews

Parent Categories