`git diff` does not work when run from a git pre-commit hook
问题 I have a git pre-commit hook that does some style checking on any modified files before committing. The implementation is irrelevant, but it starts by calling git diff . Here's what i have in (repo)/.git/hooks/pre-commit . #!/bin/sh echo "=== Running script..." git diff echo "=== Done running script..." # Other stuf # .... # Always exit with 1 so pre-commit hook always fails. # Useful for testing exit 1 When I actually try committing something, the pre-commit hook correctly fires, but the git