I have this script to check git status
for all of my repositories:
find / -type d -name .git 2>&- |
while read gitFolder; do
if [[ $gitFolder == *"/Temp/"* ]]; then
continue;
fi
if [[ $gitFolder == *"/Trash/"* ]]; then
continue;
fi
if [[ $gitFolder == *"/opt/"* ]]; then
continue;
fi
parent=$(dirname $gitFolder);
if [[ `git -C $parent status --porcelain` ]]; then
echo "";
echo $parent;
git -C $parent status --porcelain
else if [[ $(git -C $parent status | grep ahead) ]]; then
echo "";
echo "$parent is not pushed yet";
fi
done
But it's not working.
If I remove the second else-block
then it works.
Basically I want to know if a git repository has any changes (first if) or if it's ahead of master (second if).
How should I change that second if condition?