If you’re stuck working on a Git repo from a Windows environment, you might find that newly-created scripts get “permission denied” when trying to run them from a Linux environment (such as in a CI context).
There’s not a direct equivalent of chmod +x
to fix this on Windows, but we can tell Git that the given file should be marked as executable:
# new file
git add --chmod=+x path/to/script.sh
# existing file
git update-index --chmod=+x path/to/script.sh
Verify the changes:
git ls-files --stage $file
# 100755 36a56a22da809fb9c73cc91e17e874f567f60309 0 path/to/script.sh
^^^