3

From when I started committing this morning, my master pointer has been advancing but my remote/origin/master pointer has not. However, when I use the command line to check where remote origin is (ls-remote origin) as I've seen recommended on similar questions, The SHA1 returned is not the one of the commit that the remote/origin/master pointer indicates, but the one that master indicates. When I try git pull, something else I saw recommended, I'm told that I'm already up to date.

Here is what gitk is currently showing (couldn't post an image)

  • master
  • remotes/origin/master

I am the only person working on this code and very new to git and to version control in general.

Update:

Other things I've tried:

  • Tried git push, which gives me the message that everything is up-to-date

  • Tried git fetch, which does not change what I see in gitk (also tried git fetch origin)

mleewing
  • 125
  • 1
  • 5

2 Answers2

4
  1. The opposite of push is not really pull, it's fetch. In particular, git pull is essentially git fetch plus an extra step, git merge or git rebase. This matters more if you have an older version of git, because:

  2. If your git is older than 1.8.5 (my guess is that yours is), using git pull runs git fetch in such a way that the fetch step does not update the remote-tracking branch origin/master. However, if you run git fetch origin manually, it will update the remote-tracking branch (to the SHA-1 you see with git ls-remote), which will make your gitk display correct.

  3. This seems particularly odd because git push should update your remote-tracking branch, so that after git push origin master tells you that everything is up to date, gitk should now see the update, as if you had run git fetch origin. (This is true even with older git variants. The change in git 1.8.5 was to make the fetch-run-by-pull update the remote-tracking branches, to eliminate this one oddity.)

(If you have a newer version of git, the fetch that pull runs should update the remote-tracking branches, and this whole question should not arise in the first place.)


Edit: as seen in comments below, the problem turned out to be a missing fetch specification in the repository's config file. How that got created is still a mystery: normally, either the initial clone, or adding a remote named origin, will add the correct fetch = +refs/heads/*:refs/remotes/origin/* line. Should that line go missing, however, you must put it back to get the remote-tracking branches updated.

torek
  • 448,244
  • 59
  • 642
  • 775
  • Okay, I just tried git fetch origin, still no effect. – mleewing Dec 31 '14 at 20:02
  • That's particularly weird. What does `git config --get-all remote.origin.fetch` produce? (It *should* be `+refs/heads/*:refs/remotes/origin/*` and if it's something else that might explain this.) – torek Dec 31 '14 at 21:27
  • When I use `git config --get-all remote.origin.fetch` nothing happens, I just get a new line to enter commands on. – mleewing Jan 02 '15 at 14:50
  • Ah, very interesting. That would explain the lack of updates. Use either `git config --add` or `git config --edit` (or both) to add that as the `remote.origin.fetch` value (`--edit` brings up your editor, which I find is the easiest way to tweak things, but you might want to `git config --add remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'` first and then use `--edit` to view and/or fix typos). – torek Jan 02 '15 at 17:31
2

my master pointer has been advancing but my remote/origin/master pointer has not.

That seems consistent with the local nature of a commit: it adds a new commit to your local branch (master), but does not change anything for your remote tracking branch (origin/master)

You would need to push (git push) to your upstream repo in order for origin/master to change, and for git ls-remote to return a more recent commit SHA1.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. Actually, my git hub repository is up to date, looking at the website. All of my new commits and changes are reflected. When I use `git push origin master`, which is how I've always pushed, I'm told that everything is up to date. – mleewing Dec 31 '14 at 19:39
  • As usual, your answer is correct. However I think that a short note on `git fetch` (along the lines of what you have already said about `git push`) would improve it. – ChrisGPT was on strike Dec 31 '14 at 19:52
  • 1
    @Chris I agree. I believe torek's answer took care of the git fetch part. – VonC Dec 31 '14 at 20:04