Skip to content

Instantly share code, notes, and snippets.

@jefftriplett
Created November 2, 2010 16:48
Show Gist options
  • Save jefftriplett/659923 to your computer and use it in GitHub Desktop.
Save jefftriplett/659923 to your computer and use it in GitHub Desktop.
Get the name of a git branch so that it may be assigned to an environment variable.
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
@tmc
Copy link

tmc commented Nov 3, 2010

git name-rev HEAD --name-only
might be bettah

@jefftriplett
Copy link
Author

Thanks Travis. I found name-rev but I missed the --name-only switch. I was hoping someone would point out a more straight forward way.

@tmc
Copy link

tmc commented Nov 3, 2010

Np. Yeah, without name-only you might as well use the output of branches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment