Force add file permission in git.

I was working on a Windows laptop with a repo originally created on Mac, and git arbitrary changed bash script file permission from 755 to 644.

I was able to change it back by updating git index

git update-index --chmod=+x script.sh

But I couldn’t commit this change, because as far as git was concerned nothing in the file changed. But I was able to force-add the change

git add --chmod=+x -- script.sh

After that I was able to commit and push the change.

Leave a Reply

Your email address will not be published. Required fields are marked *