{"thread":{"id":"36101","subject":"howto to run git without a master branch","startedAt":"2014-03-08T21:37:21Z","lastAt":"2014-03-10T09:30:08Z","messageCount":7,"participants":["Carlos Pereira","Torsten Bögershausen","Kevin","Ilya Bobyr","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"236328","messageId":"531B8D91.6020800@ist.utl.pt","threadId":"36101","inReplyTo":null,"subject":"howto to run git without a master branch","fromName":"Carlos Pereira","fromEmail":"jose.carlos.pereira@ist.utl.pt","sentAt":"2014-03-08T21:37:21Z","receivedAt":"2014-03-08T21:37:21Z","isPatch":false,"sender":{"key":"jose.carlos.pereira@ist.utl.pt","avatar":null},"body":"Hi,\ngit newbie here.\n\nI would like to work with two main branches: master-g and master-x, \ninstead of the usual master, and apparently git does not like this.\n\nAfter creating a local repository with these two branches, and a server \nrepository with git init --bare, and pushing the two branches:\n\ngit remote add origin foo@bar:~/path/test.git\ngit push origin master-g\ngit push origin master-x\n\neverything seems fine, but cloning:\ngit clone foo@bar:~/path/test.git\nterminates with a warning: remote HEAD refers to nonexistent ref, unable \nto checkout.\n\nOn the original local repository, I have:\n >cat HEAD\nref: refs/heads/master-x\n\nBut on the server repository or the clone repository, HEAD points to \nmaster branch, that does not exist:\n >cat HEAD\nref: refs/heads/master\n\nReplacing in the HEAD file, master by master-g (on the server before \ncloning, or on the clone after cloning) seems to solve the problem.\n\nShall I worry about this? does my fix (editing directly HEAD on the \nserver) fixes really the problem? what would be the correct procedure to \navoid this?\n\nThank you!\nCarlos Pereira,\n"},{"id":"236333","messageId":"531C1C69.6080809@web.de","threadId":"36101","inReplyTo":"531B8D91.6020800@ist.utl.pt","subject":"Re: howto to run git without a master branch","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-03-09T07:46:49Z","receivedAt":"2014-03-09T07:46:49Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2014-03-08 22.37, Carlos Pereira wrote:\n> Hi,\n> git newbie here.\n> \n> I would like to work with two main branches: master-g and master-x, instead of the usual master, and apparently git does not like this.\n> \n> After creating a local repository with these two branches, and a server repository with git init --bare, and pushing the two branches:\n> \n> git remote add origin foo@bar:~/path/test.git\n> git push origin master-g\n> git push origin master-x\n> \n> everything seems fine, but cloning:\n> git clone foo@bar:~/path/test.git\n> terminates with a warning: remote HEAD refers to nonexistent ref, unable to checkout.\nThis is because Git is trying to be nice:\nWhen you clone, it tries to checkout a branch for you.\n\nWhat happens when you only have 1 branch, lets say master-x?\nIf I clone the bare repo here, with only 1 branch, this branch\nis automatically checked out (tested on 1.8.5.2)\n\nWhat happens when you have 2 branches on the server?\nGit really can not make a decision which one is the right one to check out for\nyou, so if you have 2 branched like \"master\" and \"develop\", it checks out the\n\"master\" branch for you.\n\nBut if you have \"master-x\" and \"master-g\" then Git has no clue, which one could\nbe you favorite one (and neither have I)\n\nWhat does \"git branch\" say?\n(I think nothing)\nWhat does \"git branch -r\" say?\n(I think \"origin/master-g\" and \"origin/master-x\")\n  \n> \n> On the original local repository, I have:\n>>cat HEAD\n> ref: refs/heads/master-x\n> \n> But on the server repository or the clone repository, HEAD points to master branch, that does not exist:\n>>cat HEAD\n> ref: refs/heads/master\n> \n> Replacing in the HEAD file, master by master-g (on the server before cloning, or on the clone after cloning) seems to solve the problem.\n> \n> Shall I worry about this? does my fix (editing directly HEAD on the server) fixes really the problem? \n\nNo\n\n>what would be the correct procedure to avoid this?\n(Don't worry if there is a warning, when Git tries to be nice)\n(Or feel free to send a patch to this list which improves the user experience)\n\n> \n> Thank you!\n> Carlos Pereira,\n"},{"id":"236343","messageId":"531CC6FE.2040803@ist.utl.pt","threadId":"36101","inReplyTo":"531C1C69.6080809@web.de","subject":"Re: howto to run git without a master branch","fromName":"Carlos Pereira","fromEmail":"jose.carlos.pereira@ist.utl.pt","sentAt":"2014-03-09T19:54:38Z","receivedAt":"2014-03-09T19:54:38Z","isPatch":false,"sender":{"key":"jose.carlos.pereira@ist.utl.pt","avatar":null},"body":"On 03/09/2014 07:46 AM, Torsten Bögershausen wrote:\n>> After creating a local repository with these two branches, and a server repository with git init --bare, and pushing the two branches:\n>> >  \n>> >  git remote add originfoo@bar:~/path/test.git\n>> >  git push origin master-g\n>> >  git push origin master-x\n>> >  \n>> >  everything seems fine, but cloning:\n>> >  git clonefoo@bar:~/path/test.git\n>> >  terminates with a warning: remote HEAD refers to nonexistent ref, unable to checkout.\n>>      \n> This is because Git is trying to be nice:\n> When you clone, it tries to checkout a branch for you.\n>\n> What happens when you only have 1 branch, lets say master-x?\n> If I clone the bare repo here, with only 1 branch, this branch\n> is automatically checked out (tested on 1.8.5.2)\n>\n> What happens when you have 2 branches on the server?\n> Git really can not make a decision which one is the right one to check out for\n> you, so if you have 2 branched like \"master\" and \"develop\", it checks out the\n> \"master\" branch for you.\n>\n> But if you have \"master-x\" and \"master-g\" then Git has no clue, which one could\n> be you favorite one (and neither have I)\n>    \nThe problem is on the server repo, the cloned repo is just a \nconsequence. After initializing the server repo and pushing two branches \nmaster-g and master-x there is no master branch. Therefore the HEAD file \nshould not point to a master branch that does not exist: ref: \nrefs/heads/master\n\nIt could point to master-g (the first branch to be pushed) or master-x \n(the last branch to be pushed), depending of the criterion used by git, \nbut pointing to something that does not exist seems weird and is the \ncause of the further complaints when the whole repository is cloned...\n\nI forgot to say that the git version is 1.7.2.5 in both the initial repo \nand the server repo (probably this issue was fixed in newer versions?)\n\nAs I said, editing directly the HEAD text file on the server, and \nreplacing master by master-g (or master-x) seems to solve the problem. \nMy question is: is that enough? or shall I expect further issues down \nthe road?\n\nThank you very much,\n\nCarlos\n> What does \"git branch\" say?\n> (I think nothing)\n> What does \"git branch -r\" say?\n> (I think \"origin/master-g\" and \"origin/master-x\")\n>\n>    \n"},{"id":"236344","messageId":"CAO54GHCALveaT9XSE+SvQLp7a09dy8NvqDc6ajC5TZsFGmFJ_A@mail.gmail.com","threadId":"36101","inReplyTo":"531CC6FE.2040803@ist.utl.pt","subject":"Re: howto to run git without a master branch","fromName":"Kevin","fromEmail":"ikke@ikke.info","sentAt":"2014-03-09T20:00:25Z","receivedAt":"2014-03-09T20:00:25Z","isPatch":false,"sender":{"key":"ikke@ikke.info","avatar":"https://gravatar.com/avatar/60a0d08eeccb16914fdbfc7f3441548dc827dc436d5c6900ec6600e274e53c5b?d=mp&s=160"},"body":"HEAD on the remote repo is indeed used to determine what to check out\nwhen cloning. It's quite normal to change it to anything you like. To\nchange it, you usually use git symbolic-ref HEAD master-x instead of\ndirectly editing that file.\n\nOn Sun, Mar 9, 2014 at 8:54 PM, Carlos Pereira\n<jose.carlos.pereira@ist.utl.pt> wrote:\n> On 03/09/2014 07:46 AM, Torsten Bögershausen wrote:\n>>>\n>>> After creating a local repository with these two branches, and a server\n>>> repository with git init --bare, and pushing the two branches:\n>>> >  >  git remote add originfoo@bar:~/path/test.git\n>>>\n>>> >  git push origin master-g\n>>> >  git push origin master-x\n>>> >  >  everything seems fine, but cloning:\n>>> >  git clonefoo@bar:~/path/test.git\n>>>\n>>> >  terminates with a warning: remote HEAD refers to nonexistent ref,\n>>> > unable to checkout.\n>>>\n>>\n>> This is because Git is trying to be nice:\n>> When you clone, it tries to checkout a branch for you.\n>>\n>> What happens when you only have 1 branch, lets say master-x?\n>> If I clone the bare repo here, with only 1 branch, this branch\n>> is automatically checked out (tested on 1.8.5.2)\n>>\n>> What happens when you have 2 branches on the server?\n>> Git really can not make a decision which one is the right one to check out\n>> for\n>> you, so if you have 2 branched like \"master\" and \"develop\", it checks out\n>> the\n>> \"master\" branch for you.\n>>\n>> But if you have \"master-x\" and \"master-g\" then Git has no clue, which one\n>> could\n>> be you favorite one (and neither have I)\n>>\n>\n> The problem is on the server repo, the cloned repo is just a consequence.\n> After initializing the server repo and pushing two branches master-g and\n> master-x there is no master branch. Therefore the HEAD file should not point\n> to a master branch that does not exist: ref: refs/heads/master\n>\n> It could point to master-g (the first branch to be pushed) or master-x (the\n> last branch to be pushed), depending of the criterion used by git, but\n> pointing to something that does not exist seems weird and is the cause of\n> the further complaints when the whole repository is cloned...\n>\n> I forgot to say that the git version is 1.7.2.5 in both the initial repo and\n> the server repo (probably this issue was fixed in newer versions?)\n>\n> As I said, editing directly the HEAD text file on the server, and replacing\n> master by master-g (or master-x) seems to solve the problem. My question is:\n> is that enough? or shall I expect further issues down the road?\n>\n> Thank you very much,\n>\n> Carlos\n>\n>> What does \"git branch\" say?\n>> (I think nothing)\n>> What does \"git branch -r\" say?\n>> (I think \"origin/master-g\" and \"origin/master-x\")\n>>\n>>\n>\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"236345","messageId":"531CE837.1080504@gmail.com","threadId":"36101","inReplyTo":"531CC6FE.2040803@ist.utl.pt","subject":"Re: howto to run git without a master branch","fromName":"Ilya Bobyr","fromEmail":"ilya.bobyr@gmail.com","sentAt":"2014-03-09T22:16:23Z","receivedAt":"2014-03-09T22:16:23Z","isPatch":false,"sender":{"key":"ilya.bobyr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/694419?v=4"},"body":"On 3/9/2014 12:54 PM, Carlos Pereira wrote:\n> On 03/09/2014 07:46 AM, Torsten Bögershausen wrote:\n>>> After creating a local repository with these two branches, and a \n>>> server repository with git init --bare, and pushing the two branches:\n>>> >  >  git remote add originfoo@bar:~/path/test.git\n>>> >  git push origin master-g\n>>> >  git push origin master-x\n>>> >  >  everything seems fine, but cloning:\n>>> >  git clonefoo@bar:~/path/test.git\n>>> >  terminates with a warning: remote HEAD refers to nonexistent ref, \n>>> unable to checkout.\n>> This is because Git is trying to be nice:\n>> When you clone, it tries to checkout a branch for you.\n>>\n>> What happens when you only have 1 branch, lets say master-x?\n>> If I clone the bare repo here, with only 1 branch, this branch\n>> is automatically checked out (tested on 1.8.5.2)\n>>\n>> What happens when you have 2 branches on the server?\n>> Git really can not make a decision which one is the right one to \n>> check out for\n>> you, so if you have 2 branched like \"master\" and \"develop\", it checks \n>> out the\n>> \"master\" branch for you.\n>>\n>> But if you have \"master-x\" and \"master-g\" then Git has no clue, which \n>> one could\n>> be you favorite one (and neither have I)\n> The problem is on the server repo, the cloned repo is just a \n> consequence. After initializing the server repo and pushing two \n> branches master-g and master-x there is no master branch. Therefore \n> the HEAD file should not point to a master branch that does not exist: \n> ref: refs/heads/master\n>\n> It could point to master-g (the first branch to be pushed) or master-x \n> (the last branch to be pushed), depending of the criterion used by \n> git, but pointing to something that does not exist seems weird and is \n> the cause of the further complaints when the whole repository is \n> cloned...\n\nThere is a \"git remote set-head\" to manipulate HEAD in a remote repository.\n\nThe fact that it is not set when you push master-x and master-y could be \njustified to some extent.\nI think that this only applies to a case when you are pushing into a \nrepository that have no branches.\nConsider that you do not have to push only one branch, you may push any \nset of branches you want.  And I do not think that branches in the set \nhave any meaningful order.\nAlso, your local HEAD does not necessary point to the \"most reasonable \nbranch to checkout when you clone\".  It is just your current branch.\nNow the questions is, how should the remote repository determine what to \nchange HEAD to?\n\nI agree that this might be viewed as a user experience issue.\nBut I can not come up with a possible solution.  Can you?\n\n> I forgot to say that the git version is 1.7.2.5 in both the initial \n> repo and the server repo (probably this issue was fixed in newer \n> versions?)\n>\n> As I said, editing directly the HEAD text file on the server, and \n> replacing master by master-g (or master-x) seems to solve the problem. \n> My question is: is that enough? or shall I expect further issues down \n> the road?\n\nI do not think there should be any issues.\nBasically if your repository is not using master as the \"most reasonable \nbranch to checkout when you clone\" you need to do \"git remote set-head\" \nwhen you are preparing the shared repository.\nI guess that in most setups there will be just one shared repository.\n"},{"id":"236347","messageId":"531D0043.5060507@ist.utl.pt","threadId":"36101","inReplyTo":"531CE837.1080504@gmail.com","subject":"Re: howto to run git without a master branch","fromName":"Carlos Pereira","fromEmail":"jose.carlos.pereira@ist.utl.pt","sentAt":"2014-03-09T23:58:59Z","receivedAt":"2014-03-09T23:58:59Z","isPatch":false,"sender":{"key":"jose.carlos.pereira@ist.utl.pt","avatar":null},"body":"\n> There is a \"git remote set-head\" to manipulate HEAD in a remote \n> repository.\nThanks, that is useful (like git symbolic-ref HEAD master-x suggested by \nKevin, much better than editing the text file)\n> I agree that this might be viewed as a user experience issue.\n> But I can not come up with a possible solution.  Can you?\nThe branch where the user was when he/she pushed the repo to the server? \nit would be his/her responsibility to checkout the proper branch before \npushing... if that was not good enough than he/she could always use git \nremote set-head... my point is: pointing to a bad branch that exists \nseems better than pointing to a branch that does not exist...\n\nAnyway I agree this is not important, as we can easily change HEAD.\n> I do not think there should be any issues.\nThank you very much for your answers,\n\nCarlos\n"},{"id":"236366","messageId":"874n36h04f.fsf@igel.home","threadId":"36101","inReplyTo":"531CE837.1080504@gmail.com","subject":"Re: howto to run git without a master branch","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2014-03-10T09:30:08Z","receivedAt":"2014-03-10T09:30:08Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Ilya Bobyr <ilya.bobyr@gmail.com> writes:\n\n> There is a \"git remote set-head\" to manipulate HEAD in a remote repository.\n\nThis is misleading.  The command does nothing on the remote side, it\nonly changes the refs/remote namespace in your repository.  The purpose\nis to change what branch the ref remote/<name> resolves to, ie. without\nexplicit branch name.\n\n(The only command that manipulates the remote repository is git push,\nand the plumbing beneath that.  To change HEAD in a remote repository\nyou need filesystem access to it.)\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"}]}