{"thread":{"id":"13832","subject":"[Q] Changing the current branch (HEAD) in a bare repository - how?","startedAt":"2008-06-06T15:43:59Z","lastAt":"2008-06-06T16:03:03Z","messageCount":3,"participants":["Brian Foster","Johannes Schindelin","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"78923","messageId":"a537dd660806060843p4e92932x4e0f5464c5fd1da1@mail.gmail.com","threadId":"13832","inReplyTo":null,"subject":"[Q] Changing the current branch (HEAD) in a bare repository - how?","fromName":"Brian Foster","fromEmail":"brian.foster@innova-card.com","sentAt":"2008-06-06T15:43:59Z","receivedAt":"2008-06-06T15:43:59Z","isPatch":false,"sender":{"key":"brian.foster@innova-card.com","avatar":null},"body":" Using git 1.5.2.5 (Kubuntu 7.10) and a bare repository,\n I started with (the commands and output below are typed\n in by hand, mostly from memory):\n\n    $ git branch -a\n    * master\n      foo\n    $\n\n and then changed the branch names:\n\n    $ git branch -m master old-master\n    $ git branch -m foo master\n\n and got this:\n\n    $ git branch -a\n      master\n    * old-master\n    $\n\n Now, how do I change the current branch to the (new)\n `master'?  A `checkout' fails:\n\n    $ git checkout master\n    fatal: /usr/bin/git-checkout cannot be used without a working tree.\n    $\n\n I (ultimately) hand-edited `HEAD' (apparently successfully),\n but am wondering what I should have done or may have missed?\n\n I didn't spot anything in TFM, albeit I could have easily overlooked\n or misunderstood something.\n\ncheers!\n\t-blf-\n\n-- \n\"How many surrealists does it take to   | Brian Foster\n change a lightbulb? Three. One calms   | somewhere in south of France\n the warthog, and two fill the bathtub  | Stop E$$o (ExxonMobil)!\n with brightly-coloured machine tools.\" | http://www.stopesso.com\n"},{"id":"78925","messageId":"alpine.DEB.1.00.0806061646280.1783@racer","threadId":"13832","inReplyTo":"a537dd660806060843p4e92932x4e0f5464c5fd1da1@mail.gmail.com","subject":"Re: [Q] Changing the current branch (HEAD) in a bare repository - how?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-06T15:47:04Z","receivedAt":"2008-06-06T15:47:04Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 6 Jun 2008, Brian Foster wrote:\n\n>  Using git 1.5.2.5 (Kubuntu 7.10) and a bare repository,\n>  I started with (the commands and output below are typed\n>  in by hand, mostly from memory):\n> \n>     $ git branch -a\n>     * master\n>       foo\n>     $\n> \n>  and then changed the branch names:\n> \n>     $ git branch -m master old-master\n>     $ git branch -m foo master\n> \n>  and got this:\n> \n>     $ git branch -a\n>       master\n>     * old-master\n>     $\n> \n>  Now, how do I change the current branch to the (new)\n>  `master'?\n\nvi HEAD\n\nCiao,\nDscho\n"},{"id":"78926","messageId":"m3k5h2y2iz.fsf@localhost.localdomain","threadId":"13832","inReplyTo":"a537dd660806060843p4e92932x4e0f5464c5fd1da1@mail.gmail.com","subject":"Re: [Q] Changing the current branch (HEAD) in a bare repository - how?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-06-06T16:03:03Z","receivedAt":"2008-06-06T16:03:03Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"Brian Foster\" <brian.foster@innova-card.com> writes:\n\n>  Using git 1.5.2.5 (Kubuntu 7.10) and a bare repository,\n>  I started with (the commands and output below are typed\n>  in by hand, mostly from memory):\n> \n>     $ git branch -a\n>     * master\n>       foo\n>     $\n> \n>  and then changed the branch names:\n> \n>     $ git branch -m master old-master\n>     $ git branch -m foo master\n> \n>  and got this:\n> \n>     $ git branch -a\n>       master\n>     * old-master\n>     $\n> \n>  Now, how do I change the current branch to the (new)\n>  `master'?  A `checkout' fails:\n> \n>     $ git checkout master\n>     fatal: /usr/bin/git-checkout cannot be used without a working tree.\n>     $\n\nIn a bare repository it doesn't matter (almost) which branch is\ncurrent one (there is no _checked out_ branch, so it only matters as a\ndefault checked out branch for clone, IIRC).\n \n>  I (ultimately) hand-edited `HEAD' (apparently successfully),\n>  but am wondering what I should have done or may have missed?\n\nYou have to rely on plumbing:\n\n  $ git symbolic-ref HEAD master\n\n(see documentation for details).\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}