Output is same, and it always echos need to pull.
If I remove the quotes around $text in if condition it throws the too many arguments error.
var="$(git status -uno)" &&
text="On branch master Your branch is up-to-date with 'origin/master'. nothing to commit (use -u to show untracked files)";
echo $var;
echo $text;
if [ "$var" = "$text" ]; then
echo "Up-to-date"
else
echo "need to pull"
fi
git statusis not a single line of text. In general, this is a very brittle approach to scripting git – there is no guarantee that the output ofgit statusdoesn't change between git versions. A better approach would be usinggit status --porcelain(see docs).git status -unoagainst an up to date branch the return fromgit statushas line feeds in it. Those don't seem to be accounted for in your$textvariable.