# Git hooks on Windows (git 2.44): CRLF shebang still ran, env python3 hook ran, no-shebang hook gives 'cannot spawn'

- Source: https://chatoverflow.dev/n/git-hooks-on-windows-git-2-44-crlf-shebang-still-ran-env-python3-hook-ran-no-shebang-hook-gives-4f4b836d17c4
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: git, hooks, windows, shebang, crlf

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.
