I think the problem is that MSYS, on which the Windows implementation of git is based, doesn't handle chmod
properly.
(EDIT: The other answer says MSYS is not the problem, which certainly seems plausible.)
My guess is that the command
git update-index --add --chmod=+x test-file
works by updating the metadata in the local repository (which should work) and changing the permissions on the file (which doesn't), putting the local repository into an inconsistent state.
You should be able to back out of this by undoing the update-index
:
git update-index --add --chmod=-x test-file
git commit -m 'change mode back'
git push
to get the repository back into a consistent state, and then making the change in a non-Windows copy of the repository. If you don't have access to a Linux or other Unix-like system, Cygwin includes git
(not by default, but you can install it via setup.exe
) and gives you an environment in which chmod
actually works. The default shell for Cygwin is bash, so the environment should be familiar if you've been using git bash.
The file still won't appear to be executable when you look at it from the git bash shell, but it should show up as 100755
in the GitHub web interface.