Programmatically determine if git-flow is initialized
Answered here. Basically:
- Check config for gitflow.branch.master and if the branch does exist in the repo
- Check config for gitflow.branch.develop and if the branch does exist in the repo
- Master branch can not be the same as develop branch.
- Make sure all the prefixes are configured.
What I do to check is I run following command:
git flow config >/dev/null 2>&1
. If it is initialized, then it exits with 0
otherwise with 1
.
I usually do something like this:
if $(git flow config >/dev/null 2>&1)
then
echo initialized
else
echo not initialized
git flow init -d
fi
I some time short it like:
git flow config >/dev/null 2>&1 || git flow init -d