2

I've got a repo with an origin and an upstream remote. Typically in my workflow I pull changes from my upstream, and then push them to my origin (in this case, my upstream is my company's GitHub organization's repo, the canonical one, and my origin is my fork of that).

The problem is that my upstream/master remote tracking branch doesn't seem to update with I git pull upstream master or git fetch upstream master.

So if I start out with something like this:

* d386ff8 (upstream/master, origin/master, master) commit 1

And then run git pull upstream master && git push origin master, I end up with something like this:

* 197ac91 (origin/master, master) commit 2
* d386ff8 (upstream/master) commit 1

I know that the master branch on the upstream repo is at commit 2, 197ac91 (i can verify by either visiting its github page or re-cloning the repo), so why isn't the upstream/master remote tracking branch on 197ac91 in my repo? The only time the upstream/master remote tracking branch in my repo moves is when i push to it. How do I get it to reflect where the master branch on the upstream repo actually is?

Here is my .git/config:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = false
[remote "origin"]
    url = git@github.com:me/repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "upstream"]
    url = git@github.com:mycompany/repo.git
    fetch = +refs/heads/*:refs/remotes/upstream/*

UPDATE: this seems to be a duplicate of this question. i can solve my problem by running git fetch upstream. apparently adding the master to the end of that command, for some reason, prevents the local remote tracking branches from being updated.

Community
  • 1
  • 1
aaronstacy
  • 5,696
  • 10
  • 53
  • 71

2 Answers2

1

This is mostly speculation, but from your edits and git-pull-origin-master-does-not-update-origin-master, it seems like when you specify

git pull upstream master

git notices that you've specified a fetch from upstream, and then it notices that you want to update the master branch. But instead of updating from upstream/master it sees that master has the remote origin and instead updates from there.

From the other thread, it looks like you should be using git pull upstream/master to update your local branch.

Community
  • 1
  • 1
VolatileDream
  • 1,005
  • 7
  • 15
0

If you don't push to upstream, and no one else pushed your changes, then upstream probably hasn't been updated with your latest commits.

mipadi
  • 359,228
  • 81
  • 502
  • 469
  • Sorry, I went back and clarified in the question. I know that the master branch of the upstream repo is actually on commit 2, but for some reason it's not showing that in my local repo when i run `git log`. – aaronstacy May 16 '13 at 19:42