Skip to content

Instantly share code, notes, and snippets.

@lomholdt
Created March 23, 2019 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lomholdt/26080bca50dd7427370c3f067a4eb90c to your computer and use it in GitHub Desktop.
Save lomholdt/26080bca50dd7427370c3f067a4eb90c to your computer and use it in GitHub Desktop.
# get the current branch
function get_branch {
value=$(cd $current_path; git rev-parse --abbrev-ref HEAD)
echo $value
}
# # Determine if we are in a git repo
# function is_git_repo {
# if [ -d $current_path/.git ]; then
# return 1
# elif [ $(cd $current_path; git rev-parse --is-inside-work-tree) ]; then
# return 1
# else
# return 0
# fi;
# }
# if is_git_repo; then
# get_branch
# else
# echo no branch
# fi
# Determine if we are in a git repo
if [ -d $current_path/.git ]; then
get_branch
elif [ $(cd $current_path; git rev-parse --is-inside-work-tree) ]; then
get_branch
else
echo no branch
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment