Created
February 22, 2011 22:34
-
-
Save ymendel/839575 to your computer and use it in GitHub Desktop.
git_current_branch vs. git_current_head
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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