Phil for Humanity Phil for Humanity
A Guide for the Survival of Humankind and Helping the World, Society, and Yourself.



Git Executable Permissions



Have you noticed that when you create a file in Git that the permissions typically default to 544 or "rw-r--r--"?

Even simple scripts have these non-executable permissions; however, you can still run these scripts just fine as if they are executable. The only issue is that auto-complete (tab or double escape) on the command line interface does not resolve when trying to execute scripts that do not have executable access.

The problem is that Git looks at the contents in each file to determine what file permissions each file should have. For instance, if you add either "#!/bin/sh" or "#!/bin/bash" or "#!/bin/perl" to the very first line of your scripts, then the permissions will automatically change to 755 or "rwxr-xr-x". And thus, auto-complete will start working as you expect it to.

If you are on a non-Windows computer, you should run this command too.

git update-index --chmod=+x FILENAME

In my opinion, I think this is a bad hack to circumvent Unix/Linux permissions on Windows. I personally think Git permissions on Windows should work exactly like Unix/Linux, so they are modifiable using a chmod command such as above. Thus, these permissions would be saved in the Git repository for each file on Windows. I do not understand why there is even a difference.

by Phil for Humanity
on 20120615

Related Articles
 » Git Repository Permissions
 » Git Log and Cat-File
 » ClearCase Support: Changing File Permissions