Skip to content

Instantly share code, notes, and snippets.

@ymendel
Created February 22, 2011 22:34
Show Gist options
  • Save ymendel/839575 to your computer and use it in GitHub Desktop.
Save ymendel/839575 to your computer and use it in GitHub Desktop.
git_current_branch vs. git_current_head
git_current_branch()
{
git branch 2>/dev/null | awk '/^\* /{print $2}'
}
git_current_head()
{
export BRANCH=`git branch 2>/dev/null | awk '/^\* /{print $2}'`
if [[ $BRANCH = "(no" ]]; then
export BRANCH=`git name-rev --name-only HEAD 2>/dev/null`
fi
echo $BRANCH
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment