Git set executable file permission on Windows
When interacting between Windows and Unix filesystems using Git,
setting a file to be executable takes a particular Git command from the Windows computer.
With standalone Unix systems, just chmod +x myfile.sh
is tracked by Git.
However, with Windows Subsystem for Linux or Cygwin,
this chmod +x
change is not tracked if the file resides on a Windows filesystem and
not within the WSL internal filesystem.
Windows file mode permission for executable aren’t as trivial as Unix-like chmod. Unix-like file systems such as Linux and macOS need the executable bit set correctly to execute shell scripts and binary executables as expected. On Unix-like file systems, Git propagates the executable permission of files.
To add executable permission on Windows and for all other systems, use Git command:
git update-index --chmod=+x /path/to/exe
To remove executable permission on Windows and for all other systems, use Git command:
git update-index --chmod=-x /path/to/exe
Verify the change to executable permission by:
git status --porcelain=2
which will have output including:
1 M. N… 100644 100755 100755 … /path/to/exe