git diff

Table of Contents

git diff reference

git diff --exit-code # Exits 0: no differences, 1: differences
git diff --quiet     # No outputs. Implies --exit-code
git diff --name-only # Show only names of changed files

Commit only when there's something staged howto

if ! git diff --quiet --cached; then
  git commit
fi

Or just one liner:

git diff --quiet --cached || git commit