I have a variable in bash:
branchName=$(git branch --show-current)
There are two options for the returned value:
- banch name (e.g. master)
fatal: not a git repository (or any of the parent directories): .git
I want to check if branchName
starts with fatal:
I have tried to check if it starts with master
and it works:
if [[ $branchName == master* ]];
then echo "yes"
fi
echo $branchName
Output:
yes
master
but when I try to check if it starts with fatal:
it does not work:
if [[ $branchName == fatal* ]];
then echo "yes"
fi
Output:
fatal: not a git repository (or any of the parent directories): .git