{"thread":{"id":"21983","subject":"git remote set-head not working?","startedAt":"2009-12-18T16:25:54Z","lastAt":"2009-12-18T23:55:32Z","messageCount":7,"participants":["Eugene Sajine","Jeff King","Jay Soffian","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"130076","messageId":"76c5b8580912180825t17bfc90eq20dfc05cafa8c02e@mail.gmail.com","threadId":"21983","inReplyTo":null,"subject":"git remote set-head not working?","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-12-18T16:25:54Z","receivedAt":"2009-12-18T16:25:54Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"Hi,\n\ni have a repo cloned from the server with two branches master and qa.\n\n$git remote show origin\n\ntells me that the HEAD branch is master.\n\nWhen i try to execute\n\n$ git remote set-head origin qa\n\nIt prints nothing and \"git remote show origin\" still prints that HEAD\nbranch is master.\n\nCould you, please, advise if I am i missing something.\n\nI'm working on Linux with git-1.6.4.4\n\nThanks,\nEugene\n"},{"id":"130078","messageId":"20091218165302.GA1746@sigill.intra.peff.net","threadId":"21983","inReplyTo":"76c5b8580912180825t17bfc90eq20dfc05cafa8c02e@mail.gmail.com","subject":"Re: git remote set-head not working?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-12-18T16:53:03Z","receivedAt":"2009-12-18T16:53:03Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 18, 2009 at 11:25:54AM -0500, Eugene Sajine wrote:\n\n> i have a repo cloned from the server with two branches master and qa.\n> \n> $git remote show origin\n> \n> tells me that the HEAD branch is master.\n> \n> When i try to execute\n> \n> $ git remote set-head origin qa\n> \n> It prints nothing and \"git remote show origin\" still prints that HEAD\n> branch is master.\n> \n> Could you, please, advise if I am i missing something.\n\nHmm. It probably worked, but what you are being shown is a bit\nconfusing.\n\n\"git remote show\" will actually query the remote server to find where\nits HEAD is pointing. But \"git remote set-head\" is about changing your\n_local_ idea of where the remote head is pointing (in general, \"git\nremote\" does not change anything on the remote side. It is about\nmanaging the local configuration of your remotes).\n\nAFAICT, there is no way to use \"git remote\" to query the result of your\nset-head. And the \"show\" output makes no distinction between the two.\n\nPerhaps we should print both in \"git remote show\" if they differ.\nSomething like:\n\n   HEAD branch: qa (remote points to \"master\")\n\nor\n\n   HEAD branch (local): qa\n   HEAD branch (remote): master\n\nThat would clear up the confusion of what is happening. Whether that is\nwhat you actually wanted, I don't know. If you want to be able to refer\nto \"origin/qa\" as \"origin\", then you're fine. But if you wanted to\nactually change the remote repository's idea of HEAD so that further\nclones will clone \"qa\" by default, then you can't do that with \"git\nremote\". You would have to go to the remote repository and run \"git\nsymbolic-ref\", I think.\n\n-Peff\n"},{"id":"130080","messageId":"76c5b8580912180938s2b885efax33be860f963ba92f@mail.gmail.com","threadId":"21983","inReplyTo":"20091218165302.GA1746@sigill.intra.peff.net","subject":"Re: git remote set-head not working?","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-12-18T17:38:39Z","receivedAt":"2009-12-18T17:38:39Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"> Hmm. It probably worked, but what you are being shown is a bit\n> confusing.\n>\n> \"git remote show\" will actually query the remote server to find where\n> its HEAD is pointing. But \"git remote set-head\" is about changing your\n> _local_ idea of where the remote head is pointing (in general, \"git\n> remote\" does not change anything on the remote side. It is about\n> managing the local configuration of your remotes).\n>\n> AFAICT, there is no way to use \"git remote\" to query the result of your\n> set-head. And the \"show\" output makes no distinction between the two.\n>\n> Perhaps we should print both in \"git remote show\" if they differ.\n> Something like:\n>\n>   HEAD branch: qa (remote points to \"master\")\n>\n> or\n>\n>   HEAD branch (local): qa\n>   HEAD branch (remote): master\n>\n> That would clear up the confusion of what is happening. Whether that is\n> what you actually wanted, I don't know. If you want to be able to refer\n> to \"origin/qa\" as \"origin\", then you're fine. But if you wanted to\n> actually change the remote repository's idea of HEAD so that further\n> clones will clone \"qa\" by default, then you can't do that with \"git\n> remote\". You would have to go to the remote repository and run \"git\n> symbolic-ref\", I think.\n>\n> -Peff\n>\n\nYes. I was trying to change the HEAD on the bare remote (origin) repo\nand the concept here is really confusing.\n\n\nFirstly, when i cloned from some repo \"clone\" comand is setting HEAD\nbranch for remote in accordance to where the HEAD is pointing on\norigin side. I just recently realized that and i'm not sure it is best\nthing to do - i think it should default to origin/master first, if it\ndoesn't exist then to where the HEAD is pointing.\n\nSecondly, I don't really understand what is the purpose of \"git remote\nset-head\" if the change cannot be transferred to the actual origin\nrepo, so it will start serving another branch as default? I might not\nhave access to the server to perform git symbolic-ref on my bare repo\n(imagine the repo on github), so it might be not an option.\n\nThe problem with this is that it can be screwed up easily (i did\nit;)), but the fix is not trivial.\n\nScenario i hit was:\nMy colleague created bare repo on the server and performed some\ncommits and pushed. We've got 3 branches on the server: master, qa and\nfeatureX The repo got screwed up - i was unable to clone because of\nrepository corruption (another story probably for Shawn as there was\nEgit involved;) )\nSo i tried to recover I cloned from my colleague, but his head was\npointing to featureX so I've got this featureX, when i was expecting\nto see master.\nI realized that i have to add master and qa as tracking branches for\norigin/master and origin/qa.\nThen i deleted corrupted server repo, created bare repo using \"clone\n--bare\" and put it on the server. But i didn't know that i have to\ncheckout to master branch in order for it to be default branch served\nfrom the server before cloning. So i ended up with the featureX being\ndefault HEAD on the server.\nThat was not user friendly stuff...\n\nAnd here i am trying to change this setting on the server...\n\nThanks,\nEugene\n"},{"id":"130097","messageId":"76718490912181328k5f87d82u499b7a1eba471126@mail.gmail.com","threadId":"21983","inReplyTo":"76c5b8580912180938s2b885efax33be860f963ba92f@mail.gmail.com","subject":"Re: git remote set-head not working?","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-12-18T21:28:35Z","receivedAt":"2009-12-18T21:28:35Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Fri, Dec 18, 2009 at 12:38 PM, Eugene Sajine <euguess@gmail.com> wrote:\n> Yes. I was trying to change the HEAD on the bare remote (origin) repo\n> and the concept here is really confusing.\n\nThe remote command is about updating things under .git/refs/remotes,\nnot about updating a remote server. For updating a remote server,\nthere is really only push. Clear as mud?\n\n> Firstly, when i cloned from some repo \"clone\" comand is setting HEAD\n> branch for remote in accordance to where the HEAD is pointing on\n> origin side. I just recently realized that and i'm not sure it is best\n> thing to do - i think it should default to origin/master first, if it\n> doesn't exist then to where the HEAD is pointing.\n\nIt is expected that the person setting up the bare repo is the person\nwho knows best which is the \"default\" branch. Which is why clone uses\nthe remote HEAD as the default branch to checkout.\n\nBut, if you don't like that, you can always use:\n\n% git clone -b master ...\n\nAnd you'll get master checked out instead of whatever the remote HEAD is.\n\n> Secondly, I don't really understand what is the purpose of \"git remote\n> set-head\" if the change cannot be transferred to the actual origin\n> repo, so it will start serving another branch as default?\n\nHmm, the man page says:\n\n       set-head\n           Sets or deletes the default branch ($GIT_DIR/remotes/<name>/HEAD)\n           for the named remote. Having a default branch for a remote is not\n           required, but allows the name of the remote to be specified in lieu\n           of a specific branch. For example, if the default branch for origin\n           is set to master, then origin may be specified wherever you would\n           normally specify origin/master.\n\nThis seems clear to me, but I guess if you expect that \"git remote\"\nupdates the remote server I can see some confusion. Perhaps the\nDESCRIPTION for git remote should include something like:\n\n\"This command updates the local repository only. For updating a remote\nrepository, see git push.\"\n\n> I might not\n> have access to the server to perform git symbolic-ref on my bare repo\n> (imagine the repo on github), so it might be not an option.\n\nUnderstood. I'm not sure whether the send-pack/receive-pack protocol\nsupports the notion of \"I want to change what HEAD points to.\"\n\nj.\n"},{"id":"130099","messageId":"7veimst0w6.fsf@alter.siamese.dyndns.org","threadId":"21983","inReplyTo":"76718490912181328k5f87d82u499b7a1eba471126@mail.gmail.com","subject":"Re: git remote set-head not working?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-18T21:42:17Z","receivedAt":"2009-12-18T21:42:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> On Fri, Dec 18, 2009 at 12:38 PM, Eugene Sajine <euguess@gmail.com> wrote:\n>> Yes. I was trying to change the HEAD on the bare remote (origin) repo\n>> and the concept here is really confusing.\n>\n> The remote command is about updating things under .git/refs/remotes,\n> not about updating a remote server. For updating a remote server,\n> there is really only push. Clear as mud?\n\nWe still support (and unfortunately we would probably end up supporting\nfor a long time) \"remote update\" so it is not strictly true, but that is\nthe original motivation behind \"git remote\" subcommand.\n\n> Understood. I'm not sure whether the send-pack/receive-pack protocol\n> supports the notion of \"I want to change what HEAD points to.\"\n\nIt does not support it, but that is not because there is a strong reason\nit shouldn't.\n"},{"id":"130104","messageId":"76718490912181424l3815ce95o6dcde77ea00cbd11@mail.gmail.com","threadId":"21983","inReplyTo":"7veimst0w6.fsf@alter.siamese.dyndns.org","subject":"Re: git remote set-head not working?","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-12-18T22:24:48Z","receivedAt":"2009-12-18T22:24:48Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Fri, Dec 18, 2009 at 4:42 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jay Soffian <jaysoffian@gmail.com> writes:\n>\n>> The remote command is about updating things under .git/refs/remotes,\n>> not about updating a remote server. For updating a remote server,\n>> there is really only push. Clear as mud?\n>\n> We still support (and unfortunately we would probably end up supporting\n> for a long time) \"remote update\" so it is not strictly true, but that is\n> the original motivation behind \"git remote\" subcommand.\n\nBut \"remote update\" updates the local repo from the remote, it doesn't\ndo anything to the remote itself. That is the point I was trying to\nmake clear -- \"git remote\" doesn't ever do anything to the remote\nrepo, it only updates things on the local repo.\n\n>> Understood. I'm not sure whether the send-pack/receive-pack protocol\n>> supports the notion of \"I want to change what HEAD points to.\"\n>\n> It does not support it, but that is not because there is a strong reason\n> it shouldn't.\n\nOkay. I'm sure deciding where to place the command \"I want to update\nwhat HEAD on remote points to\" would be a fun discussion. :-)\n\nj.\n"},{"id":"130109","messageId":"76c5b8580912181555i39484811t3aa641254c07dcce@mail.gmail.com","threadId":"21983","inReplyTo":"76718490912181328k5f87d82u499b7a1eba471126@mail.gmail.com","subject":"Re: git remote set-head not working?","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-12-18T23:55:32Z","receivedAt":"2009-12-18T23:55:32Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"> The remote command is about updating things under .git/refs/remotes,\n> not about updating a remote server. For updating a remote server,\n> there is really only push. Clear as mud?\n>\n> It is expected that the person setting up the bare repo is the person\n> who knows best which is the \"default\" branch. Which is why clone uses\n> the remote HEAD as the default branch to checkout.\n>\n> But, if you don't like that, you can always use:\n>\n> % git clone -b master ...\n\ndidn't know that, thanks!\n\n>> Secondly, I don't really understand what is the purpose of \"git remote\n>> set-head\" if the change cannot be transferred to the actual origin\n>> repo, so it will start serving another branch as default?\n>\n> Hmm, the man page says:\n>\n>       set-head\n>           Sets or deletes the default branch ($GIT_DIR/remotes/<name>/HEAD)\n>           for the named remote. Having a default branch for a remote is not\n>           required, but allows the name of the remote to be specified in lieu\n>           of a specific branch. For example, if the default branch for origin\n>           is set to master, then origin may be specified wherever you would\n>           normally specify origin/master.\n>\n> This seems clear to me, but I guess if you expect that \"git remote\"...\n\nterms i'll use here:\nremote - instance created using git remote add or by cloning\norigin - actual remote repo I cloned from\n\nIf it would be exactly as you said then it would probably not be so confusing.\nThe problem here is that if set-head is only about the remote, then\nwhy after i change it from master to qa and \"git show remote origin\"\ndoesn't show this change? Bug? Probably, because \"git show remote\norigin\" actually queries origin for this info and always shows origin\nHEAD branch, as Jeff pointed out. If this is the case then there is an\ninconsistency between those two commands which caused this confusion.\nPlease, correct me If i'm wrong but i really think that there should\nbe a way to not only set it up for remote but also for origin , where\nthe remote points to if you have push rights of course.\n\nOf course all of this could be avoided if I knew that i have to be\nexplicit during cloning from my colleagues, because their HEAD may be\npointing to some BUTT, which I don't even want to know about;)\n\nThanks,\nEugene\n"}]}