Why is my Git pre-commit hook not executable by default?
My context - web development Node.js. I needed to add husky functionality, but got an error, probably to the disk access. This helped in my situation:
chmod ug+x .husky/*
chmod ug+x .git/hooks/*
Because files are not executable by default; they must be set to be executable.
The sample files from a git init
are all executable; if it's copied or renamed to a non-sample file, it will retain the original file's x
flag.
New files will be created with current defaults. In your case, view those defaults with umask
:
$ umask
0022
By default, new files won't be u+x
unless explicitly set to be.