6

Is the message a bit mis-leading?

When checkout a branch (eg., b535), git does it and says "Your branch is up-to-date with 'origin/b535'." That sounds like what I have in my local branch b535 is up-to-date.

$ git checkout b535
Previous HEAD position was 8aa0145... master - resyns
Switched to branch 'b535'
Your branch is up-to-date with 'origin/b535'.

But actually it's not. When doing a git pull, it found updates from remote and updating local branch.

$ git pull origin b535
remote: Counting objects: 39, done.
remote: Compressing objects: 100% (39/39), done.
remote: Total 39 (delta 31), reused 0 (delta 0)
Unpacking objects: 100% (39/39), done.
...
artm
  • 17,291
  • 6
  • 38
  • 54

2 Answers2

10

Well, your branch is up to date with the last known position of origin/b535. If you want git status to give you more accurate info without having to do a git pull, do a git fetch instead. This will update origin/b535, without changing your local b535.

David Deutsch
  • 17,443
  • 4
  • 47
  • 54
  • 2
    Yeah thanks - so the message could probably: "Your branch is up-to-date with last-known 'origin/b535'." It'd give novice users more warning I suppose.. But yes you help make it clear. – artm Feb 03 '16 at 20:37
  • 1
    `origin/b535` is the name of the tracking branch, which is what it's up-to-date with respect to. Confusing, perhaps, but accurate. :-P – hobbs Feb 03 '16 at 20:39
  • @artm: May be 'with local copy of' instead of 'last-known' – Eugen Konkov Aug 16 '16 at 12:28
3

This is because Git can only know about what it has downloaded. Your local copy of origin/b535 may or may not be up-to-date with your origin remote.

You need to manually git fetch to ensure your origin branches are in sync with your Git server...Git won't do that for you automatically with the status command.

For an up-to-date status command you could define an alias like this:

[alias]
    rstatus = "!git fetch && git status"
Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115