Try:
(尝试:)
git config core.fileMode false
From git-config(1) :
(从git-config(1) :)
core.fileMode Tells Git if the executable bit of files in the working tree is to be honored. Some filesystems lose the executable bit when a file that is marked as executable is checked out, or checks out a non-executable file with executable bit on. git-clone(1) or git-init(1) probe the filesystem to see if it handles the executable bit correctly and this variable is automatically set as necessary. A repository, however, may be on a filesystem that handles the filemode correctly, and this variable is set to true when created, but later may be made accessible from another environment that loses the filemode (eg exporting ext4 via CIFS mount, visiting a Cygwin created repository with Git for Windows or Eclipse). In such a case it may be necessary to set this variable to false. See git-update-index(1). The default is true (when core.filemode is not specified in the config file).
The -c
flag can be used to set this option for one-off commands:
(-c
标志可用于为一次性命令设置此选项:)
git -c core.fileMode=false diff
And the --global
flag will make it be the default behavior for the logged in user.
(并且--global
标志将使其成为登录用户的默认行为。)
git config --global core.fileMode false
Changes of the global setting won't be applied to existing repositories.
(全局设置的更改不会应用于现有存储库。)
You have to either clone the repository again or execute git init
. (您必须再次克隆存储库或执行git init
。)
This is safe on existing repositories. (这对现有存储库是安全的。)
It will not overwrite things that are already there. (它不会覆盖已存在的东西。)
Warning (警告)
core.fileMode
is not the best practice and should be used carefully.
(core.fileMode
不是最佳做法,应谨慎使用。)
This setting only covers the executable bit of mode and never the read/write bits. (此设置仅涵盖模式的可执行位,而不包括读/写位。)
In many cases you think you need this setting because you did something like chmod -R 777
, making all your files executable. (在许多情况下,您认为您需要此设置,因为您执行了类似chmod -R 777
,使您的所有文件都可执行。)
But in most projects most files don't need and should not be executable for security reasons . (但是在大多数项目中, 出于安全原因,大多数文件不需要也不应该是可执行的 。)
The proper way to solve this kind of situation is to handle folder and file permission separately, with something like:
(解决这种情况的正确方法是分别处理文件夹和文件权限,例如:)
find . -type d -exec chmod a+rwx {} ; # Make folders traversable and read/write
find . -type f -exec chmod a+rw {} ; # Make files read/write
If you do that, you'll never need to use core.fileMode
, except in very rare environment.
(如果你这样做,你将永远不需要使用core.fileMode
,除非在非常罕见的环境中。)