{"thread":{"id":"44589","subject":"Re: EXT: Re: \"Your branch is ahead of 'origin' by X commits\"","startedAt":"2016-12-01T22:04:03Z","lastAt":"2016-12-01T22:55:14Z","messageCount":4,"participants":["Alfonsogonzalez, Ernesto (GE Digital)","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"306762","messageId":"D465DC74.B911%ernesto.alfonsogonzalez@ge.com","threadId":"44589","inReplyTo":null,"subject":"Re: EXT: Re: \"Your branch is ahead of 'origin' by X commits\"","fromName":"Alfonsogonzalez, Ernesto (GE Digital)","fromEmail":"ernesto.alfonsogonzalez@ge.com","sentAt":"2016-12-01T22:03:33Z","receivedAt":"2016-12-01T22:04:03Z","isPatch":false,"sender":{"key":"ernesto.alfonsogonzalez@ge.com","avatar":null},"body":"Hi Jeff,\n\nI followed all your steps, but didn¹t find anything.\n\n$ ls -d .git\n.git\n$ ls .git/master\nls: .git/master: No such file or directory\n$ git show HEAD\ncommit 92d392c37e376db69d61dafdc427b379d860fb5a\nMerge: 6be322c 5544904\n...\n$ git show refs/heads/master\ncommit 92d392c37e376db69d61dafdc427b379d860fb5a\nMerge: 6be322c 5544904\n...\n$ git rev-parse --symbolic-full-name master\nrefs/heads/master\n$\n\nThen I realized that the message should say,\n\n\"Your branch is ahead of Œorigin/master' by X commits\"\nAnd not\n\n\"Your branch is ahead of 'origin' by X commits²\n\n\nSo I used branch ‹set-upstream and see the expected behavior.\n\n$ git branch --set-upstream-to=origin/master\nBranch master set up to track remote branch master from origin.\n$ git status\nOn branch master\nYour branch is up-to-date with 'origin/master'.\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n ...\nnothing added to commit but untracked files present (use \"git add\" to\ntrack)\n$ \n\n\n\n\nI¹m still not sure what it means for the branch upstream to be ³origin²\nonly.\n\nI do have 2 remotes. A 2nd remote, called ³teamname-origin², is indeed\nbehind my local master by 108 commits.\n\nSo it seems there is a bug. When master¹s upstream is ³origin², it was\nactually pointing to ³teamname-origin/master², which is behind by 108\ncommits.\n\nHowever, pushing, pulling, rebasing, etc, all work against the correct\nremote (³origin²). \n\nSo this could be a bug in git status?\n\nThanks,\n\nErnesto\n\n\nOn 12/1/16, 1:47 PM, \"Jeff King\" <peff@peff.net> wrote:\n\n>On Thu, Dec 01, 2016 at 07:49:40PM +0000, Alfonsogonzalez, Ernesto (GE\n>Digital) wrote:\n>\n>> $ git diff origin/master\n>> $ git status\n>> On branch master\n>> Your branch is ahead of 'origin' by 108 commits.\n>>   (use \"git push\" to publish your local commits)\n>> Untracked files:\n>>   (use \"git add <file>...\" to include in what will be committed)\n>\n>The \"master\" we are talking about here must always be\n>\"refs/heads/master\", since it will have come from resolving the HEAD\n>symbolic ref.\n>\n>But here:\n>\n>> $ git show origin/master --oneline\n>> 92d392c Merge pull request #21 from org/branch\n>> \n>> $ git show master --oneline\n>> 92d392c Merge pull request #21 from org/branch\n>\n>The \"master\" in the second case could possibly find \"master\" as another\n>name. Is it possible you have a .git/master file (this may have been\n>created by accidentally running \"git update-ref master\" instead of \"git\n>update-ref refs/heads/master\")?\n>\n>Or other things you could check:\n>\n>  # see what's on HEAD, which we know points to refs/heads/master\n>  git show HEAD\n>\n>  # or just check refs/heads/master itself\n>  git show refs/heads/master\n>\n>  # or just ask what \"master\" resolves to\n>  git rev-parse --symbolic-full-name master\n>\n>That last one actually seems to complain that \"refname 'master' is\n>ambiguous' if you do have .git/master. I think that's a minor bug, as it\n>should presumably follow the normal disambiguation rules used for lookup\n>(in which .git/master always takes precedence over refs/heads/master).\n>\n>-Peff\n\n"},{"id":"306763","messageId":"xmqqy3zz70lc.fsf@gitster.mtv.corp.google.com","threadId":"44589","inReplyTo":"D465DC74.B911%ernesto.alfonsogonzalez@ge.com","subject":"Re: EXT: Re: \"Your branch is ahead of 'origin' by X commits\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-12-01T22:20:47Z","receivedAt":"2016-12-01T22:20:55Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alfonsogonzalez, Ernesto (GE Digital)\"\n<ernesto.alfonsogonzalez@ge.com> writes:\n\n> I'm still not sure what it means for the branch upstream to be 'origin'\n> only.\n\nIf only you checked who the upstream of your 'master' was before\ndoing the set-upstream-to, it would have been trivial to answer that\nquestion, but that is water under the bridge now.\n\nA wild guess is that the upstream of your 'master' was 'origin/HEAD'\n(whose name, when fully spelled out, is \"refs/remotes/origin/HEAD\"),\nwhich pointed to something other than \"refs/remotes/origin/master\"?\n\n"},{"id":"306765","messageId":"20161201222354.yu2q62udi56ygyoz@sigill.intra.peff.net","threadId":"44589","inReplyTo":"D465DC74.B911%ernesto.alfonsogonzalez@ge.com","subject":"Re: EXT: Re: \"Your branch is ahead of 'origin' by X commits\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-12-01T22:23:55Z","receivedAt":"2016-12-01T22:24:01Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Dec 01, 2016 at 10:03:33PM +0000, Alfonsogonzalez, Ernesto (GE Digital) wrote:\n\n> So I used branch ‹set-upstream and see the expected behavior.\n> \n> $ git branch --set-upstream-to=origin/master\n> Branch master set up to track remote branch master from origin.\n\nAh, that makes sense.\n\n> I¹m still not sure what it means for the branch upstream to be ³origin²\n> only.\n\nThe name \"origin\" generally resolves to refs/remotes/origin/HEAD, which\nis a symbolic ref pointing to the \"default branch\" for that remote.\nThat's generally set at clone time from what the remote has in its HEAD,\nbut you can update it with \"git remote set-head\" if you want to.\n\nBut that's just for resolving the name; I'm not sure that it would work\nto set a branch's upstream to just \"origin\".  Do you possibly have\nanother ref named origin?\n\n-Peff\n"},{"id":"306770","messageId":"D465E524.B977%ernesto.alfonsogonzalez@ge.com","threadId":"44589","inReplyTo":"20161201222354.yu2q62udi56ygyoz@sigill.intra.peff.net","subject":"Re: EXT: Re: \"Your branch is ahead of 'origin' by X commits\"","fromName":"Alfonsogonzalez, Ernesto (GE Digital)","fromEmail":"ernesto.alfonsogonzalez@ge.com","sentAt":"2016-12-01T22:36:10Z","receivedAt":"2016-12-01T22:55:14Z","isPatch":false,"sender":{"key":"ernesto.alfonsogonzalez@ge.com","avatar":null},"body":"Yes, it looks like I had a local branch “origin” which was behind by 108\ncommits. \n\nSetting upstream to the local branch correctly states \"track local branch\norigin”.\n\nIt was my mistake, there is no bug.\n\nThanks,\n\n\n$ git rev-parse --symbolic-full-name origin\nrefs/heads/origin\n# origin is a local branch\n\n$ git show refs/heads/origin\ncommit ad8c3ee6cb7740627e4ecddb418c826bc8597d3d # old commit, 108 commits\nbehind master\n\n\n$ git branch\n...\n* master\n...\n  origin\n...\n\n$ git show origin \ncommit ad8c3ee6cb7740627e4ecddb418c826bc8597d3d\nMerge: e16bda3 4b7564d\n\n$ git branch --set-upstream-to=origin/master\nBranch master set up to track remote branch master from origin\n\n\n$ git branch --set-upstream-to=origin #correctly says \"track local branch\norigin\"\nBranch master set up to track local branch origin.\n\n$ git status\nOn branch master\nYour branch is ahead of 'origin' by 108 commits.\n  (use \"git push\" to publish your local commits)\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n...\nnothing added to commit but untracked files present (use \"git add\" to\ntrack)\n\n\n$ git branch -d origin\nDeleted branch origin (was ad8c3ee).\n$\n\n$ git status\nOn branch master\nYour branch is based on 'origin', but the upstream is gone.\n  (use \"git branch --unset-upstream\" to fixup)\n\n\n\n\nOn 12/1/16, 2:23 PM, \"Jeff King\" <peff@peff.net> wrote:\n\n>On Thu, Dec 01, 2016 at 10:03:33PM +0000, Alfonsogonzalez, Ernesto (GE\n>Digital) wrote:\n>\n>> So I used branch ‹set-upstream and see the expected behavior.\n>> \n>> $ git branch --set-upstream-to=origin/master\n>> Branch master set up to track remote branch master from origin.\n>\n>Ah, that makes sense.\n>\n>> I¹m still not sure what it means for the branch upstream to be ³origin²\n>> only.\n>\n>The name \"origin\" generally resolves to refs/remotes/origin/HEAD, which\n>is a symbolic ref pointing to the \"default branch\" for that remote.\n>That's generally set at clone time from what the remote has in its HEAD,\n>but you can update it with \"git remote set-head\" if you want to.\n>\n>But that's just for resolving the name; I'm not sure that it would work\n>to set a branch's upstream to just \"origin\".  Do you possibly have\n>another ref named origin?\n>\n>-Peff\n\n"}]}