{"thread":{"id":"16518","subject":"remote branch checkout issue, why its *(no branch)","startedAt":"2008-11-28T22:15:14Z","lastAt":"2008-11-28T23:24:59Z","messageCount":3,"participants":["Sudipta GHOSH","Jakub Narebski","Björn Steinbrink"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"96697","messageId":"9e6474ae0811281415n7b4596afq7b3ce25816d9a639@mail.gmail.com","threadId":"16518","inReplyTo":null,"subject":"remote branch checkout issue, why its *(no branch)","fromName":"Sudipta GHOSH","fromEmail":"sudipta.in@gmail.com","sentAt":"2008-11-28T22:15:14Z","receivedAt":"2008-11-28T22:15:14Z","isPatch":false,"sender":{"key":"sudipta.in@gmail.com","avatar":null},"body":"Hi,\n\nIn Our git repository there are few branches like\n\nmaster\norgin/B1\norigin/B2\n\nAfter doing  #git checkout orgin/B1 I found that my current branch is\n*(no branch)\n\n#git branch\n*(no branch)\nmaster\n\nWhy its showing *(no branch) why not origin/B1\n\nHow I can checkout orgin/B1 and after that my current branch will be\norgin/B1 not the *(no branch)\n\nRegards,\n-SG\n"},{"id":"96699","messageId":"m3k5anjxcd.fsf@localhost.localdomain","threadId":"16518","inReplyTo":"9e6474ae0811281415n7b4596afq7b3ce25816d9a639@mail.gmail.com","subject":"Re: remote branch checkout issue, why its *(no branch)","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-11-28T22:32:56Z","receivedAt":"2008-11-28T22:32:56Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"Sudipta GHOSH\" <sudipta.in@gmail.com> writes:\n\n> In our git repository there are few branches like\n> \n> master\n> origin/B1\n> origin/B2\n> \n> After doing  #git checkout origin/B1 I found that my current branch is\n> *(no branch)\n> \n> #git branch\n> *(no branch)\n> master\n> \n> Why its showing *(no branch) why not origin/B1\n> \n> How I can checkout origin/B1 and after that my current branch will be\n> origin/B1 not the *(no branch)\n\nFirst, 'origin/B1' is so called remote-tracking branch, and its full\nname is refs/remotes/origin/B1.  Those branches are updated\n_automatically_ by git on fetch, to follow branch 'B1' in 'origin'\nrepository.  Therefore, to not lose _your_ changes git doesn't allow\nchecking out remote-tracking branches.  You can checkout _state_ of\nsuch branch into anonymous noname branch, so called in git jargon\n\"detached HEAD\".\n\n\nWhat you can do is to create _local_ branch, closely tied to\nremote-tracking branch 'origin/B1', by using:\n\n  $ git branch -b B1 --track origin/B1\n\nGit would set up configuration for this branch in such way that \"git\npull\" command given on 'B1' branch would \"do the right thing\"(TM)\n\n\nI really recommend reading \"Git User's Manual\" or \"The Git Community\nBook\" first...\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"96702","messageId":"20081128232459.GA5956@atjola.homenet","threadId":"16518","inReplyTo":"m3k5anjxcd.fsf@localhost.localdomain","subject":"Re: remote branch checkout issue, why its *(no branch)","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-11-28T23:24:59Z","receivedAt":"2008-11-28T23:24:59Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.11.28 14:32:56 -0800, Jakub Narebski wrote:\n> What you can do is to create _local_ branch, closely tied to\n> remote-tracking branch 'origin/B1', by using:\n> \n>   $ git branch -b B1 --track origin/B1\n\nYou mixed up checkout and branch there ;-)\n\nIt's either\n\ngit branch B1 origin/B1 # Just create a branch B1\n\nor\n\ngit checkout -b B1 origin/B1 # Create and checkout B1\n\nI omitted the \"--track\" as, by default, it is implied when you create a\nnew branch from a remote tracking branch.\n\nBjörn\n"}]}