0

My remote repository is on a private network and I must use a VPN to reach it. If I do not connect to the VPN....

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

If I then connect to the VPN...

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

The problem is that I know there are changes in the remote repo. If I then do...

$ git pull
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 6), reused 0 (delta 0)
Unpacking objects: 100% (8/8), done.
From gitlab.corp.local:jschank/capitol-connect-dev
   f3d1e85..2f3ee1b  master     -> origin/master
Updating f3d1e85..2f3ee1b
Fast-forward
 Vagrantfile                            |  7 ++++++-
 provisioning/puppet/capitol-connect.pp |  4 ++--
 provisioning/shell/setup-symlinks.sh   | 19 +------------------
 3 files changed, 9 insertions(+), 21 deletions(-)

Why is git status not reporting that my local repo is behind my remote? What am I missing here? It kinda renders git status completely unreliable.

$ git --version
git version 2.2.1
jschank
  • 554
  • 1
  • 5
  • 16
  • 3
    Git does not contact the remote unless/until you specifically ask it to, with `git ls-remote` (a read-only operation that updates nothing in your copy), `git fetch` (update your copy of their stuff without merging), or `git pull` (update your copy and then run `git merge` to add their changes to your current branch, after which you're no longer behind). The step you really want here is `git fetch`; read more here and elsewhere about how `pull` is just `fetch`-then-`merge`, and you should be sure you want to merge before doing the merge (if you're sure, then "pull" is fine). – torek Dec 31 '14 at 21:33
  • Thanks for the quick reply @torek... Since `git status` will often tell me if I am ahead or behind the remote, then I think I have reasonable expectations about the behavior of `git status` is there some way to configure git so that it will proactively consult the remote rather than just assuming I am up-to-date? – jschank Dec 31 '14 at 21:56
  • I think I found my answer on this post... [git check if pull needed][1] [1]: http://stackoverflow.com/questions/3258243/git-check-if-pull-needed – jschank Dec 31 '14 at 22:00
  • Hmmm, I don't seem to be able to mark this question as answered. – jschank Dec 31 '14 at 22:01
  • That's because I only made a comment, not an answer :-) You could (or I could) mark this as a duplicate of the other, though. – torek Dec 31 '14 at 22:20
  • @torek: it isn't obvious to me how to mark this question as a dupe, and thus close it. Can you explain how to do that? – jschank Jan 01 '15 at 19:53
  • You probably need more reputation even if you're the question's author, I guess. I'll do it... – torek Jan 01 '15 at 19:59

0 Answers0