1

The output of git status command

$ git status

On branch master is following:

Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

Considering this is a local git status check, and I have master branch checked out (and it is the only branch available), then, in the above message - "Your branch" - I believe that it means my local master branch?

And when it says "is up-to-date with 'origin/master'", what does origin/master mean here? I am already on the local master which is origin/master isn't it? Or does it mean Master branch on the server (require network connectivity to server/automatic fetch)?

variable
  • 8,262
  • 9
  • 95
  • 215
  • 1
    Possible duplicate of [In Git, what is the difference between origin/master vs origin master?](https://stackoverflow.com/questions/18137175/in-git-what-is-the-difference-between-origin-master-vs-origin-master) – Daniel A. White Oct 08 '19 at 16:26

2 Answers2

4

origin/master is the tracking branch that is synched to the branch master on the remote repository identified by origin.

In other words: it's the closest thing git has to a "remote branch". Every time you fetch from the remote repository (or pull) that branch will be updated.

Since origin/master will usually only be updated by a fetch/pull command that also means that git status doesn't necessarily tell you if your local code is up-to-date with the remote repository unless you recently executed a fetch/pull. In other words: git status causes no network traffic.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
  • Does git status command connect to the remote server to check what has changed? – variable Oct 08 '19 at 16:20
  • @variable: no, the only git commands that actually talk to remote servers are "fetch" and "push" (well, and any commands that execute one of these under the hood, such as "pull", which is basically just "fetch" followed by "merge"). – Joachim Sauer Oct 08 '19 at 16:22
  • So am I right to say that git has got locally - 1) the locally commited code and 2) all versions of last known commited code from the server (this is stored locally as part of git clone or git fetch). And got status checks point1 with latest verison of point 2. Right? – variable Oct 08 '19 at 16:27
0

origin is the default name given to the remote repository from which your local repository was cloned. origin/master is the master branch of that repository, which (by default) your local master branch will track.

Mert Köklü
  • 2,183
  • 2
  • 16
  • 20