I\'m just starting to look into Git hooks, but I can\'t seem to get them to run.
I set up a local repository, so there is now a \'.git\' directory in my project folder.
If it helps anyone: I was getting following error:
error: cannot spawn .git/hooks/pre-commit: No error
Turned out that in my pre-commit file I did not have 'newline' character after last exit command:
#!/bin/sh
# From gist at https://gist.github.com/chadmaughan/5889802
# stash any unstaged changes
git stash -q --keep-index
# run the tests with the gradle wrapper
./gradlew test --daemon
# store the last exit code in a variable
RESULT=$?
# unstash the unstashed changes
git stash pop -q
# return the './gradlew test' exit code
exit $RESULT
# << must have a newline after above command >>
I was running gradle project on windows and gradle commands in cmder shell and cmd