ghooks/pre-commit-staged-check.sh

15 lines
443 B
Bash
Raw Normal View History

#!/bin/sh
case $GIT_INDEX_FILE in
*.lock)
if GIT_INDEX_FILE=${GIT_INDEX_FILE%.lock} git status --porcelain | grep '^M'
then
echo "Error: Found both staged and unstaged changes when trying to commit with 'git commit -a'."
echo "Do two seperate commits with, 'git commit -m ...' and 'git commit -a -m ...'"
echo "Or 'git reset .' and then 'git commit -a -m ...' for a single commit"
exit 1
fi
;;
esac