{"thread":{"id":"26583","subject":"Feature Request: add a --current option to git branch","startedAt":"2011-02-23T19:08:28Z","lastAt":"2011-02-23T19:47:23Z","messageCount":3,"participants":["John Jendro","Jay Soffian","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"162044","messageId":"AANLkTimDE18XK8NOg++pxqs5LCJZ4m67Ygo4JvYDbw+F@mail.gmail.com","threadId":"26583","inReplyTo":null,"subject":"Feature Request: add a --current option to git branch","fromName":"John Jendro","fromEmail":"tacliat@gmail.com","sentAt":"2011-02-23T19:08:28Z","receivedAt":"2011-02-23T19:08:28Z","isPatch":false,"sender":{"key":"tacliat@gmail.com","avatar":null},"body":"Yes I know this can be done with sed & grep, but --current should be a\nstandard thing for git branch to have.\n\n-- \n\n-John Jendro\n"},{"id":"162048","messageId":"AANLkTikecya+o+rLVHJARv06mCtEv-Ef1nRECQH0saLr@mail.gmail.com","threadId":"26583","inReplyTo":"AANLkTimDE18XK8NOg++pxqs5LCJZ4m67Ygo4JvYDbw+F@mail.gmail.com","subject":"Re: Feature Request: add a --current option to git branch","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-02-23T19:32:07Z","receivedAt":"2011-02-23T19:32:07Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Feb 23, 2011 at 2:08 PM, John Jendro <tacliat@gmail.com> wrote:\n> Yes I know this can be done with sed & grep, but --current should be a\n> standard thing for git branch to have.\n\nI sense you're looking to get the name of the currently checked out\nbranch, possibly for use in a script. In that case, you may want \"git\nrev-parse --abbrev-ref HEAD\" or \"git rev-parse --symbolic-full-name\nHEAD\" depending upon what you're trying to do.\n\nj.\n"},{"id":"162049","messageId":"7vbp228rec.fsf@alter.siamese.dyndns.org","threadId":"26583","inReplyTo":"AANLkTikecya+o+rLVHJARv06mCtEv-Ef1nRECQH0saLr@mail.gmail.com","subject":"Re: Feature Request: add a --current option to git branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-02-23T19:47:23Z","receivedAt":"2011-02-23T19:47:23Z","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 Wed, Feb 23, 2011 at 2:08 PM, John Jendro <tacliat@gmail.com> wrote:\n>> Yes I know this can be done with sed & grep, but --current should be a\n>> standard thing for git branch to have.\n>\n> I sense you're looking to get the name of the currently checked out\n> branch, possibly for use in a script. In that case, you may want \"git\n> rev-parse --abbrev-ref HEAD\" or \"git rev-parse --symbolic-full-name\n> HEAD\" depending upon what you're trying to do.\n\nAnd if you are not scripting, then the completion script we ship (it was\noriginally done for use with bash but I was told that it also can be used\nwith zsh) may help.\n\nNote that the completion script shows how to do this properly---if you\nare indeed scripting, it may be a good idea to study it, but the gist of\nit is:\n\n\tif b=$(git symbolic-ref HEAD 2>/dev/null)\n        then\n\t\techo \"You are on branch ${b#refs/heads/}\"\n\telse\n\t\techo \"You are not on any branch\"\n\tfi\n"}]}