I had a few merge failures when i git squashed my branch into master. I excepted it to leave the commit unmerged and let me merge and then push it myself. But in this case it just pushed broken code to the master with all the conflict markers.
It could be fixed by just checking the git merge result
Perhaps this code....
if [ $CODE -eq 0 ];then
echo "Merge Failed. Please fix it and do a git commit"
exit $CODE
fi