{"thread":{"id":"38928","subject":"Change default branch name (server side) while cloning a repository","startedAt":"2015-03-27T12:27:21Z","lastAt":"2015-03-27T16:47:14Z","messageCount":4,"participants":["Garbageyard","Stefan Näwe","Matthieu Moy","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"258590","messageId":"1427459241861-7627964.post@n2.nabble.com","threadId":"38928","inReplyTo":null,"subject":"Change default branch name (server side) while cloning a repository","fromName":"Garbageyard","fromEmail":"varuag.chhabra@gmail.com","sentAt":"2015-03-27T12:27:21Z","receivedAt":"2015-03-27T12:27:21Z","isPatch":false,"sender":{"key":"varuag.chhabra@gmail.com","avatar":"https://gravatar.com/avatar/b731428347fdc09c456902cac39c52957f1e296e8edd38f6162400e8402f480e?d=mp&s=160"},"body":"We use Gitolite for access control and i have admin access on Git server. I\nwanted to make sure that whenever a new repository is created and is then\ncloned on any machine, the default branch should point to mainline. To do\nthis, when I run the repository creation script, i change the content of\nfile HEAD of a given repository to point to mainline i.e., default entry of\n“ref: refs/heads/master” in file HEAD is changed to “ref:\nrefs/heads/mainline”.\n\nFor example, if \"work\" is the repository name, then on Git server,\n\n[gitolite@gitserver  repositories]$ cd work.git/\n\n[gitolite@gitserver  work.git]$ cat HEAD\nref: refs/heads/mainline\n\nIf i now clone the repository on my local machine, then the default branch\nshould be pointing to mainline and not master. However, the issue is that it\nstill points to master. Am I /wrong/ in assuming that changing the entry in\nfile HEAD for a given repository on Git server will change the default\nbranch while cloning? If I’m wrong, can anyone please tell me how can I\nenforce this change on the /server/ side correctly?\n\n\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/Change-default-branch-name-server-side-while-cloning-a-repository-tp7627964.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"258591","messageId":"551568CF.2050301@atlas-elektronik.com","threadId":"38928","inReplyTo":"1427459241861-7627964.post@n2.nabble.com","subject":"Re: Change default branch name (server side) while cloning a repository","fromName":"Stefan Näwe","fromEmail":"stefan.naewe@atlas-elektronik.com","sentAt":"2015-03-27T14:27:27Z","receivedAt":"2015-03-27T14:27:27Z","isPatch":false,"sender":{"key":"stefan.naewe@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4468?v=4"},"body":"Am 27.03.2015 um 13:27 schrieb Garbageyard:\n> We use Gitolite for access control and i have admin access on Git server. I\n> wanted to make sure that whenever a new repository is created and is then\n> cloned on any machine, the default branch should point to mainline. To do\n> this, when I run the repository creation script, i change the content of\n> file HEAD of a given repository to point to mainline i.e., default entry of\n> “ref: refs/heads/master” in file HEAD is changed to “ref:\n> refs/heads/mainline”.\n> \n> For example, if \"work\" is the repository name, then on Git server,\n> \n> [gitolite@gitserver  repositories]$ cd work.git/\n> \n> [gitolite@gitserver  work.git]$ cat HEAD\n> ref: refs/heads/mainline\n> \n> If i now clone the repository on my local machine, then the default branch\n> should be pointing to mainline and not master. However, the issue is that it\n> still points to master. Am I /wrong/ in assuming that changing the entry in\n> file HEAD for a given repository on Git server will change the default\n> branch while cloning? If I’m wrong, can anyone please tell me how can I\n> enforce this change on the /server/ side correctly?\n\nWorks for me with  \"gitolite3 v3.6.2-24-g8e36230 on git 2.3.4\".\n\nCould it be that the repo was emtpy when you tried to clone it ?\n\nStefan\n-- \n----------------------------------------------------------------\n/dev/random says: Half of the people in the world are below average.\npython -c \"print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')\" \nGPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9  9666 829B 49C5 9221 27AF\n"},{"id":"258595","messageId":"vpqmw2ytmuk.fsf@anie.imag.fr","threadId":"38928","inReplyTo":"1427459241861-7627964.post@n2.nabble.com","subject":"Re: Change default branch name (server side) while cloning a repository","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-03-27T16:40:51Z","receivedAt":"2015-03-27T16:40:51Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Garbageyard <varuag.chhabra@gmail.com> writes:\n\n> If i now clone the repository on my local machine, then the default branch\n> should be pointing to mainline and not master. However, the issue is that it\n> still points to master. Am I /wrong/ in assuming that changing the entry in\n> file HEAD for a given repository on Git server will change the default\n> branch while cloning? If I’m wrong, can anyone please tell me how can I\n> enforce this change on the /server/ side correctly?\n\nIIRC, there's a known limitation of the Git protocol which does not\ntransmit symbolic ref over the network. Only the HEAD's sha1 is\ntransmitted and the client guesses which branch should be checked out\nbased on this. But it can guess incorrectly if several branches point to\nthe same commit.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"258596","messageId":"20150327164714.GA10191@peff.net","threadId":"38928","inReplyTo":"551568CF.2050301@atlas-elektronik.com","subject":"Re: Change default branch name (server side) while cloning a repository","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-03-27T16:47:14Z","receivedAt":"2015-03-27T16:47:14Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 27, 2015 at 03:27:27PM +0100, Stefan Näwe wrote:\n\n> > If i now clone the repository on my local machine, then the default branch\n> > should be pointing to mainline and not master. However, the issue is that it\n> > still points to master. Am I /wrong/ in assuming that changing the entry in\n> > file HEAD for a given repository on Git server will change the default\n> > branch while cloning? If I’m wrong, can anyone please tell me how can I\n> > enforce this change on the /server/ side correctly?\n> \n> Works for me with  \"gitolite3 v3.6.2-24-g8e36230 on git 2.3.4\".\n\nIt may be related to the version.\n\nPrior to v1.8.4.3, git servers did not communicate the symbolic ref data\nto the client. The client guessed it based on which branch had the same\nsha1 as HEAD, and if there was ambiguity, it guessed \"master\" over\nothers. So it would usually work, but would sometimes have odd results.\n\nIn v1.8.4.3, the server started advertising the name of the branch. You\nneed the client and server both to be that version or more recent for it\nto work (otherwise, git falls back to the guessing behavior).\n\n-Peff\n"}]}