Can't commit update-index on Windows

2019-04-15 14:46发布

问题:

I have a executable file called post_deploy that's run on my OpenShift gear after a push, but it wasn't executable so I ran:

git update-index --chmod=+x .openshift/action_hooks/post_deploy

But every time I did a git add to commit the file, the file would loose the executable permission. If I tried to do a commit, git would tell me there was nothing to commit. I eventually had to pop over to Cygwin to get it to work, but how can I get this to work in Window's Command Prompt?

回答1:

Check your Git version: with Git 2.9.1, you can add with chmod

git add --chmod=+x -- yourFile

Also check the value of git config core.filemode. I suspect it should be false (which is expected in an environment which does not support executable bit).
Still, the add --chmod=+x should be enough to record that executable bit in the Git repo.

Finally, clone your repo in a Linux/Cygwin environment and check if the file is not already executable there.


The OP NicholasJohn16 reports below using "How do I remove files saying “old mode 100755 new mode 100644” from unstaged changes in Git?" to solve the issue.