How to change file permissions in Git on Windows?

From windows 7 environment, After  created a build.sh file and pushed it to original, but the project's build failed: ./build.sh: Permission denied. The cause is this build.sh doesn't have execute permission. So I need to add +x permission to it, on windows?

Solution:

As we know, Git manages file permissions for each file in the repository, so we need to have the executable bit set for shell/bash files to make them executable in Linux System. But on windows, file permissions do not map to the Git file permissions, so it may be a bit hard to change the file permissions. Here are the steps:
  1. check current file permission:
    C:\Git\myProject>git ls-tree HEAD
    100644 blob 55c0287d4ef21f15b97eb1f107451b88b479bffe build.sh
  2. change it to 755:
    C:\Git\myProject>git update-index --chmod=+x build.sh
  3. commit our change:
    C:\Git\myProject>git commit -m "Changing file permissions"
    [master 77b171e] Changing file permissions 0 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build.sh
  4. check permission again:
    C:\Git\myProject>git ls-tree HEAD
    100755 blob 55c0287d4ef21f15b97eb1f107451b88b479bffe build.sh
  5. push
    git push origin master

No comments:

Post a Comment

Genuine websites to earn money.

If you are interested in PTC sites then this article is for you. I have personally tried many of the sites and found that the best thing ...