Skip to content

Instantly share code, notes, and snippets.

@renanivo
Created March 6, 2015 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renanivo/4f5069fac7300503a783 to your computer and use it in GitHub Desktop.
Save renanivo/4f5069fac7300503a783 to your computer and use it in GitHub Desktop.
Pre-commit script to avoid an empty commit
LIST_MODIFIED=$(git diff-index --name-status --cached HEAD | grep -w '^.*$' | sed 's/^.\{2\}//')
if [ ${#LIST_MODIFIED[@]} -eq 0 ]; then
echo "\033[33mNothing to commit, genius!\033[39m""]]"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment