Git |> Avoid Error When Nothing to Commit
Checking the exit code of git diff
git diff-index --quiet HEAD || git commit -m 'bla'
Not produce the correct result if there are differences only between the index and work tree.
Improve Answer:
git diff-index --quiet --cached HEAD || git commit -m 'bla'
Other solution:
git commit -m 'bla' --allow-empty
Not good enough, it would actually create a commit though.
Reference:
