A hook fails with `/usr/bin/env: 'bash\r': No such file or directory`.
IntermediateTroubleshootingSubmodules, LFS and Hooks
Answer
Likely causes → The hook script has Windows CRLF line endings, so the shebang interpreter becomes bash\r. Usually caused by core.autocrlf=true on Windows checking out scripts with CRLF and then a Linux/WSL/container shell running them.
Diagnose →
file .githooks/pre-commit # "with CRLF line terminators"
git ls-files --eol .githooks/
Fix → Force LF for scripts and renormalize:
printf '*.sh text eol=lf\n.githooks/* text eol=lf\n' >> .gitattributes
git add --renormalize .
git commit -m "Force LF for scripts"
Locally fix the file with dos2unix .githooks/pre-commit.
Prevent → Commit a .gitattributes with eol=lf for all shell scripts from day one.
More on Submodules, LFS and Hooks
`fatal: No url found for submodule path 'libs/common' in .gitmodules`IntermediateAfter cloning, the submodule directories exist but are empty.Beginner`git submodule update` fails: `fatal: remote error: upload-pack: not our ref 3f2a9c1...` and `Fetched in submodule path 'libs/common', but it did not contain 3f2a9c1. Direct fetching of that commit failed.`Intermediate`git status` keeps showing `modified: libs/common (new commits)` even though you never touched it.BeginnerYou committed inside a submodule, ran `git submodule update`, and your commits vanished.Intermediate`git submodule add` fails with `fatal: 'libs/common' already exists in the index`.Intermediate