【填坑】Windows 克隆远程仓库文件权限被修改的问题

问题描述:

git clone 下来的仓库出现权限问题

old mode 100755  
new mode 100644

问题原因

当 checkout 标记为可执行的文件或 checkout 带有可执行位的非可执行文件时,一些文件系统会丢失可执行位。7(111) 丢掉可执行位为 6 (110)。

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 (e.g. 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).

解决方案:

方法 1. 使用一下指令解决:

git config core.filemode false

方法 2. 在 clone 时添加参数

git clone --config core.filemode=false YOUR_REPOSITORY

方法3 . 修改文件权限

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

参考

  1. How do I remove files saying “old mode 100755 new mode 100644” from unstaged changes in Git?
  2. Git file permissions on Windows

猜你喜欢

转载自blog.csdn.net/qq_20515461/article/details/107769346