1

I often use git status when looking in folders that may not have been synchronised with their repo for a while, just to see where I am. If I see your branch is up to date... then I assume it's ok to start working and committing.

However I just had this happen:

MINGW64 /path/to/my/project (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

MINGW64 /path/to/my/project (master)
$ git pull
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From gitlab.mydomain.com/project
   f5b203f..4ecb3eb  master     -> origin/master
Updating f5b203f..4ecb3eb
Fast-forward
 CHANGELOG | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 CHANGELOG

MINGW64 /path/to/my/project (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Why did my first git status command not realise that there was a file missing?

If it's relevant, there are currently only two commits and two files in the repo. In the 2nd commit I added the CHANGELOG file.

Syntax Error
  • 1,600
  • 1
  • 26
  • 60

2 Answers2

3

git status doesn't perform any communication outside of the local repository. It knows only about those things you've done locally to your repository as well as some comparisons against remote tracking refs indicating the last known state of the remote repository. It doesn't actually update those tracking refs.

To see if there are any new changes on the server you must first do a git fetch before doing the git status.

Parker Coates
  • 8,520
  • 3
  • 31
  • 37
0

"your branch is up to date" means that your local master branch is up to date with your local origin/master. origin is only updated when you git fetch or git pull (which is essentially a shorthand for fetching and merging).

So, if you want to make sure that you are up to date with the latest remote changes, you should git fetch (this will only update your origin branches, it won't affect your local branches) and then run git status.

Mureinik
  • 297,002
  • 52
  • 306
  • 350