【填坑】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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值