简体   繁体   English

如何chmod 0777一个文件并提交到Windows上的Git?

[英]How to chmod 0777 a file and commit as is to Git on Windows?

I'm working on Windows and on the production there's a Linux system and I'd like to chmod some files to 0777, but I don't know how to do it on Windows. 我正在开发Windows,并且在生产中有一个Linux系统,我想将一些文件chmod到0777,但我不知道如何在Windows上进行操作。 I rather not do it on production, because I'm unable to commit/push there. 我宁愿不在生产上这样做,因为我无法提交/推动那里。

Is there a way to chmod 0777 a file on Windows and commit it to Git so that it stays 0777 when I clone/pull on the production? 有没有办法在Windows上chmod 0777一个文件并将其提交给Git,以便在我克隆/拉动生产时它保持0777?

If you want to mark the file as executable, you can use 如果要将文件标记为可执行文件,则可以使用

git update-index --chmod=+x <your_file>

If you really want to have the file writable for everyone, you would have to set up a post-update hook on the linux system, because git does not track file permissions, only the executable bit. 如果你真的想让每个人都可以写文件,你必须在linux系统上设置一个post-update挂钩,因为git不跟踪文件权限,只跟踪可执行位。

An alternative solution is to install Cygwin on Windows. 另一种解决方案是在Windows上安装Cygwin

Cygwin emulates a Unix-like environment but all cygwin programs run natively on your Windows machine. Cygwin模拟类似Unix的环境,但所有cygwin程序都在Windows机器上本机运行。 It is not a virtual machine. 它不是虚拟机。 However, cygwin binaries are compiled with the cygwin libraries which allows them to understand stuff like unix style file permissions that normal Windows programs don't understand. 但是,cygwin二进制文件是使用cygwin库编译的,这使得他们可以理解正常Windows程序无法理解的unix样式文件权限等内容。

So you need to install a version of git for Cygwin. 所以你需要为Cygwin安装一个git版本。 Just select git from the Cygwin installer when first installing Cygwin. 首次安装Cygwin时,只需从Cygwin安装程序中选择git即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM