I am trying to create a bash variable which I can use to refer to my current branch in Git: something like $branch.
When adding: branch=$(git symbolic-ref --short -q HEAD)
into my bash_profile
, I keep getting: fatal: Not a git repository (or any of the parent directories): .git
when I start a new terminal.
Furthermore, echo $branch
does not print out the branch name, as git symbolic-ref --short -q HEAD
would.
I'd like to be able to use it not to print out the branch name (I already have that in my prompt) but to do things like:
git push origin $branch