swaldman: A cute fluffy sheep curled up dreaming of Dreamwidth. Labelled "Simon: Bodger". (dw-dev)
Simon ([personal profile] swaldman) wrote in [site community profile] dw_dev2013-09-07 06:01 pm
Entry tags:

Your branch is ahead of 'upstream/develop' by 540 commits.

~/dw (develop)$ git status
# On branch develop
# Your branch is ahead of 'upstream/develop' by 540 commits.

Did we ever figure out what causes this? I have a theory, but I don't really understand...

(Theory: the dwu script does "git pull --ff-only upstream develop" straight from the remote repo into the local develop branch. This doesn't update the local copy of "remotes/upstream/develop" that was created by a "git fetch" sometime in the past. This is what the current branch is being compared to. I have no idea whether this makes sense, and if so how to deal with it...)
kareila: Taking refuge from falling debris under a computer desk. (computercrash)

[personal profile] kareila 2013-09-07 05:55 pm (UTC)(link)
I'm not sure your theory is correct, but if it is, then I think typing "git fetch upstream" would bring it back into sync. That's weird though, because I thought doing a pull included fetching.

Is your upstream remote the canonical DW repo, or your fork of it? If it's your fork, you'll occasionally need to pull from the former and push back to the latter to keep them in sync. I don't use the "dwu" script so I have no idea if or how it handles that situation, but that might be what's going on?
shadowspar: Side-on picture of a Commodore 64c computer (commodore 64c)

[personal profile] shadowspar 2013-09-08 02:36 am (UTC)(link)

I think kar has p.much nailed it -- for some reason, your upstream remote isn't getting updated with changes from dreamwidth. Bear with me while I think out loud:

"Your branch is ahead of '[remote]/[branchname]' by 540 commits" is Git's funny way of saying that, according to its current state of knowledge, your local branch currently has 540 commits that aren't present on the remote. Conversely, when Git says your branch is behind, your local branch is missing commits that are present on the remote. (And hilariously enough, it's possible to be both "ahead" and "behind" at the same time...)

When you pull commits into your local branch from dreamwidth, your local branch moves ahead of your forked branch on Github -- your local branch now has all those changes from the mainline of DW development, but your branch on Github doesn't have them yet. So if you have your branch on Github set up as the remote named 'origin', then after a pull from dreamwidth, git push origin develop will send all those commits over to it, making its contents the same as your local branch. And every time you pull in an update from dreamwidth, you'll have to push those new commits back to origin to avoid seeing the "x commits ahead" message.

I'm not sure which version of the dwu script you've got -- it's changed over time -- but the current one in the wiki does push back to the remote named 'origin'. It fetches from the remote named 'dreamwidth'. Do you by chance have a third remote named 'upstream'? If so, that might explain why 'upstream' is always behind -- it's never getting updated.

To see what remotes you have and what they're pointed at, try git remote -v:

twilight:~/git/dw-free rick$ git remote -v
dreamwidth      git://github.com/dreamwidth/dw-free.git (fetch)
dreamwidth      git://github.com/dreamwidth/dw-free.git (push)
origin  git://github.com/rickscott/dw-free.git (fetch)
origin  git@github.com:rickscott/dw-free.git (push)

Then you can see how the local↔remote branches are wired up for a specific remote with git remote show <remotename>:

twilight:~/git/dw-free rick$ git remote show origin
* remote origin
  Fetch URL: https://rickscott@github.com/rickscott/dw-free.git
  Push  URL: https://rickscott@github.com/rickscott/dw-free.git
  HEAD branch: develop
  Remote branches:
    bug4650-gitify-bootstrap.pl              tracked
    bug5003-remove-hg-links                  tracked
    bug5117-lolno                            tracked
    bug5149-youtube-embed-rel-urls           new (next fetch will store in remotes/origin)
    master                                   tracked
    release-1.13                             tracked
    release-1.14                             tracked
    release-1.16                             new (next fetch will store in remotes/origin)
    scratchpad-5149                          tracked
  Local branch configured for 'git pull':
    scratchpad-5149 merges with remote scratchpad-5149
  Local refs configured for 'git push':
    develop         pushes to develop         (local out of date)
    master          pushes to master          (up to date)
    scratchpad-5149 pushes to scratchpad-5149 (up to date)
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2013-09-08 04:32 am (UTC)(link)
You are the best [personal profile] shadowspar out of all the [personal profile] shadowspars ever <3
shadowspar: Side-on picture of a Commodore 64c computer (commodore 64c)

[personal profile] shadowspar 2013-09-08 02:31 pm (UTC)(link)
AIUI, git pull remotename branchname is exactly equivalent to git fetch remotename ; git merge remotes/remotename/branchname. Too, I'm pretty sure Git updates the branch pointers under remotes/ every time it talks to the remote in question, although if this isn't happening for some reason, it'd explain why it thinks you are behind the upstream branch you just pulled from.

Is this happening on your Dreamhack, by chance? If so, d'you mind if I take a look at your git repository there and see if I can figure out what's going on?
alierak: (Default)

[personal profile] alierak 2013-09-09 05:42 pm (UTC)(link)
Note that the wiki dwu script does "git fetch dreamwidth", while [personal profile] swaldman's does not do any explicit fetch. If pull is exactly equivalent to fetch plus merge, I don't get why this would matter.

ETA: Aha, okay, git pull --ff-only is not equivalent to fetch + merge, "it doesn't fetch all upstream commits (just the ones for the branch you're working on)". (Unfortunately the reference for this is a StackOverflow question with an agenda, not official documentation, but oh well.)
Edited 2013-09-09 18:10 (UTC)
fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)

[personal profile] fu 2013-09-20 04:32 am (UTC)(link)

If you're still unsure, make a new top-level post to see if anyone else has any objections :)

sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2013-09-24 01:30 pm (UTC)(link)
I know I've had odd issues in the past when manually doing a fetch/merge instead of a pull. I expected the two to be equivalent, but that wasn't the case. I don't remember what happened, though.
geekosaur: Chuck the FreeBSD Daemon (geek)

[personal profile] geekosaur 2013-09-08 02:49 pm (UTC)(link)
The question is whether it's "tracked" or not, I think. Tracked branches get updated automatically. "remotes" is not a magic prefix, just a convention; it's the tracked status that actually matters.
fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)

[personal profile] fu 2013-09-10 12:29 am (UTC)(link)
Hmm. That makes sense, but it appears to be tracked (as it should be), based on [personal profile] swaldman's comment above:

Remote branches:
develop tracked