Updating file permissions with git-bash on Windows 7

blueberryfields picture blueberryfields · Sep 8, 2014 · Viewed 28.2k times · Source

How do I update file permissions with git-bash on Windows 7?

I've tried the following without success:

$ ls -al scripts/script.sh
-rw-r--r--    1 myUid   Administ       70 Sep  8 11:24 scripts/script.sh

$ git update-index --chmod=+x scripts/script.sh

$ ls -al scripts/script.sh
-rw-r--r--    1 myUid   Administ       70 Sep  8 11:24 scripts/script.sh

$ chmod +x scripts/script.sh

$ ls -al scripts/script.sh
-rw-r--r--    1 myUid   Administ       70 Sep  8 11:24 scripts/script.sh

Answer

Yogu picture Yogu · Sep 8, 2014

You are probably using NTFS or FAT32 on Windows, and those filesystems do not support the executable permission. Instead, cygwin looks at the file name and contents to determine whether it's executable:

Files are considered to be executable if the filename ends with .bat, .com or .exe, or if its content starts with #!.

So you should make sure that the bash file starts with a shebang (e.g. #!/bin/bash). Then, you should be able to just execute the file, disregarding the permission output of ls.