Windows own file permissions does not map to the Git file permissions so it may be a bit hard to change file permissions when you are on Windows. This is how you do it:
Lets assume the file script.sh needs to have the executable bit set. Use the command git ls-tree to inspect the file permissions:
C:\views\myproject>git ls-tree HEAD
100644 blob 55c0287d4ef21f15b97eb1f107451b88b479bffe script.sh
As you can see the file has 644 permission (ignoring the 100). We would like to change it to 755:
C:\views\myproject>git update-index --chmod=+x script.sh
C:\views\myproject>git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: script.sh
#
The file is now staged. Note that the file contents is not changed, only the meta data. We must commit the file so save the change:
C:\views\myproject>git commit -m "Changing file permissions"
[master 77b171e] Changing file permissions
0 files changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 script.sh
Running git ls-tree again to see the change:
C:\views\myproject>git ls-tree HEAD
100755 blob 55c0287d4ef21f15b97eb1f107451b88b479bffe script.sh
Thank you, this was just what I needed. :)
ReplyDeleteThanks a lot for this solution !!
ReplyDeletebut how to do for folder and it's complete file and folder
ReplyDeleteI don't think it can be done for folders?
ReplyDeleteAt least I am pretty sure Git doesn't actually track folders, only the files in them. I've found it impossible to add an empty folder to Git for example.
Cant we make file executable from git UI?
ReplyDeleteNice. Thank you!
ReplyDeletegreat, thank you!
ReplyDelete