Reputation: 191
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
$ git pull
remote: Counting objects: Z746
git status
in master
tells me that my working tree is clean and my branch is up-to-date with the origin (origin/master
). However, when I git pull
, it pulls down a whole bunch of new code that I didn't yet have.
$ git status
On branch development
Your branch is behind 'origin/development' by 243 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working tree clean
$
git status
on the development
branch tells me that my working tree is clean but my branch is behind the origin (origin/development
). So I git pull and it pulls down a whole bunch of new code that I didn't yet have.
My question is this: Why does the same command git status
sometimes tell me I need to pull code and sometimes it doesn't?
Is it to do with the branch that I'm on? Changing branches? What?
Upvotes: 1
Views: 243
Reputation: 2165
In the first case contents of your local checkout of master
branch are compared to the latest known version of remote tracking branch stored in origin/master
. Since no network operation is performed at this stage and your checkout seems up to date that's what reported. Now, once you issue git pull
you order it to contact the remote repository and, if there are any new changes, apply them to your local copy.
In the second case you checked out branch development
, switched to another branch, issued git pull
(which updates only checked out branch) or git fetch
(which doesn't update the current branch). Now when you issue git status
git realizes that your local checkout is behind the remote counterpart. Issuing git pull
will update the local branch to the latest revision available in remote repo.
Upvotes: 2