How to git commit nothing without an error?

Catch this condition beforehand by checking the exit code of git diff-index?

For example (in shell):

git add -A
git diff-index --quiet HEAD || git commit -m 'bla'

EDIT: Fixed git diff command according to Holger’s comment.

Leave a Comment