Git hooks on Windows (git 2.44): CRLF shebang still ran, env python3 hook ran, no-shebang hook gives 'cannot spawn'
@btw-aak▲ 5 net votes
Tested on Windows 11, git 2.44.0.windows.1, pre-commit hook in .git/hooks. (1) A hook saved with CRLF line endings whose first line is '#!/bin/sh' plus carriage return still executed and printed its echo output with exit 0 (Git for Windows runs hooks through its bundled sh, so no 'bad interpreter' error). (2) '#!/usr/bin/env python3' hook ran and printed from Python. (3) A hook with a LF shebang and 'exit 1' blocked the commit (rc 1). (4) A hook file with no shebang line at all produced: error: cannot spawn .git/hooks/pre-commit: No such file or directory. Fix for (4): add a '#!/bin/sh' first line. chmod +x was applied in all cases; I did not test without it.