git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Feature Request: add a --current option to git branch
@ 2011-02-23 19:08 John Jendro
  2011-02-23 19:32 ` Jay Soffian
  0 siblings, 1 reply; 3+ messages in thread
From: John Jendro @ 2011-02-23 19:08 UTC (permalink / raw)
  To: git

Yes I know this can be done with sed & grep, but --current should be a
standard thing for git branch to have.

-- 

-John Jendro

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Feature Request: add a --current option to git branch
  2011-02-23 19:08 Feature Request: add a --current option to git branch John Jendro
@ 2011-02-23 19:32 ` Jay Soffian
  2011-02-23 19:47   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Jay Soffian @ 2011-02-23 19:32 UTC (permalink / raw)
  To: John Jendro; +Cc: git

On Wed, Feb 23, 2011 at 2:08 PM, John Jendro <tacliat@gmail.com> wrote:
> Yes I know this can be done with sed & grep, but --current should be a
> standard thing for git branch to have.

I sense you're looking to get the name of the currently checked out
branch, possibly for use in a script. In that case, you may want "git
rev-parse --abbrev-ref HEAD" or "git rev-parse --symbolic-full-name
HEAD" depending upon what you're trying to do.

j.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Feature Request: add a --current option to git branch
  2011-02-23 19:32 ` Jay Soffian
@ 2011-02-23 19:47   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2011-02-23 19:47 UTC (permalink / raw)
  To: John Jendro; +Cc: Jay Soffian, git

Jay Soffian <jaysoffian@gmail.com> writes:

> On Wed, Feb 23, 2011 at 2:08 PM, John Jendro <tacliat@gmail.com> wrote:
>> Yes I know this can be done with sed & grep, but --current should be a
>> standard thing for git branch to have.
>
> I sense you're looking to get the name of the currently checked out
> branch, possibly for use in a script. In that case, you may want "git
> rev-parse --abbrev-ref HEAD" or "git rev-parse --symbolic-full-name
> HEAD" depending upon what you're trying to do.

And if you are not scripting, then the completion script we ship (it was
originally done for use with bash but I was told that it also can be used
with zsh) may help.

Note that the completion script shows how to do this properly---if you
are indeed scripting, it may be a good idea to study it, but the gist of
it is:

	if b=$(git symbolic-ref HEAD 2>/dev/null)
        then
		echo "You are on branch ${b#refs/heads/}"
	else
		echo "You are not on any branch"
	fi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-23 19:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-23 19:08 Feature Request: add a --current option to git branch John Jendro
2011-02-23 19:32 ` Jay Soffian
2011-02-23 19:47   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).