Video in progress

Strong Middle 🌿 Git

CI fails with `./mvnw: Permission denied`, while everything works locally. How does Git store file permissions, and how do you fix this?

Git stores only one permission bit: a file is executable (100755) or regular (100644). A mvnw committed from Windows or with core.fileMode=false stays 644. You need to run git update-index --chmod=+x mvnw and commit.

📖 Answer

First we look at what is recorded in the repo:

git ls-files -s mvnw
# 100644 3f2a...  0   mvnw    ← not executable

The fix:

git update-index --chmod=+x mvnw
git commit -m "mvnw'ga executable ruxsat"

This works on Windows too, because we are changing the mode in the index, not the file on disk.

Why it worked locally: on macOS or Linux you ran chmod +x on the file yourself, but that may not have made it into the commit. If you have core.fileMode=false set (the default on Windows, and sometimes people set it on macOS too to get rid of "noise"), Git does not notice the permission change at all.

There is a reverse problem too: files whose code did not change show up in the diff with old mode 100644 / new mode 100755. This is usually because someone ran chmod -R 755 on a whole folder. You should catch such a commit in review.

Writing RUN chmod +x mvnw in the Dockerfile, or calling it as sh mvnw, works, but that is fighting the symptom. The right fix is in the repo. .gitattributes does not help here: it controls line endings and diff/merge behavior, not permissions.