3

I have noticed several times in the last few months, that sometime after pushing changes to my remote repo (GitHub, though I don't think it matters) my local git will believe the changes it has have not been pushed. In all cases, these are changes that do in face exist on the remote. Most-recently was this morning. I did git pull origin master on my machine at work to fetch three commits that were made from home. Then, when I did git status it showed the same three changes as local changes that have not been pushed to the remote.

Usually, I just delete the local repository and re-clone it from GH, but to be honest I'm getting tired of doing that. Between 4 machines sharing this code, it's starting to get silly how often I have to do this.

Does this sound familiar to anyone? Is there a better solution than to just blow away and re-clone? This has happened on Mac OS and Linux systems both, so I don't think it is specific to any OS.

rjray
  • 5,525
  • 4
  • 31
  • 37

1 Answers1

3

Running git pull origin master doesn't update the remote-tracking branch origin/master. This will cause git to think you have local unpushed changes. Assuming origin/master is your default pull branch you can just say git pull or git pull origin and it will update that branch. Or you could use git fetch origin followed by git merge origin/master.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • Interesting. I've always used `git pull origin master`, but this only happens occasionally, not consistently? Either way, doing `git pull origin` (without `master`) seems to have cleaned it up. – rjray Oct 12 '12 at 20:51
  • @rjray: Maybe you (or some script/app you use) also routinely does a `git fetch` or `git remote update`? If your remote-tracking branch is already up-to-date, then `git pull origin master` will not cause the appearance of local unpushed commits. – Lily Ballard Oct 12 '12 at 20:55
  • @rjray: the remote-tracking branch `origin/master` will also be updated when you push your `master` to `master` in `origin`, which may be why `origin/master` is sometimes up-to-date for you. – Mark Longair Oct 12 '12 at 20:55