在Windows 7上使用git-bash更新文件权限 [英] Updating file permissions with git-bash on Windows 7

查看:815
本文介绍了在Windows 7上使用git-bash更新文件权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows 7上使用 git-bash 更新文件权限?



我试过了没有成功:

  $ ls -al scripts / script.sh 
-rw-r - r-- 1 myUid Administ 70 Sep 8 11:24 scripts / script.sh

$ git update-index --chmod = + x scripts / script.sh

$ ls -al scripts / script.sh
-rw -r - r-- 1 myUid Administ 70 Sep 8 11:24 scripts / script.sh

$ chmod + x scripts / script.sh

$ ls -al scripts / script.sh
-rw -r - r-- 1 myUid Administ 70 Sep 8 11:24 scripts / script.sh
可执行文件权限。相反, cygwin会查看文件名和内容以确定它是否可执行


如果文件名以.bat,.com或.exe结尾,或者其内容以#开头, !。

所以你应该确保bash文件以 shebang (例如#!/ bin / bash )。然后,您应该可以执行该文件,忽略 ls 的权限输出。


How do I update file permissions with git-bash on Windows 7?

I've tried the following without success:

$ ls -al scripts/script.sh
-rw-r--r--    1 myUid   Administ       70 Sep  8 11:24 scripts/script.sh

$ git update-index --chmod=+x scripts/script.sh

$ ls -al scripts/script.sh
-rw-r--r--    1 myUid   Administ       70 Sep  8 11:24 scripts/script.sh

$ chmod +x scripts/script.sh

$ ls -al scripts/script.sh
-rw-r--r--    1 myUid   Administ       70 Sep  8 11:24 scripts/script.sh

解决方案

You are probably using NTFS or FAT32 on Windows, and those filesystems do not support the executable permission. Instead, cygwin looks at the file name and contents to determine whether it's executable:

Files are considered to be executable if the filename ends with .bat, .com or .exe, or if its content starts with #!.

So you should make sure that the bash file starts with a shebang (e.g. #!/bin/bash). Then, you should be able to just execute the file, disregarding the permission output of ls.

这篇关于在Windows 7上使用git-bash更新文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆