Syn*_*sso 157 windows git diff file-permissions
我已经阅读了一些关于Git文件权限的问题,我仍然有点困惑.我在GitHub上有一个来自另一个的回购.合并后,它们应该是相同的.然而:
$ git diff --summary origin/epsilon master/epsilon
mode change 100644 => 100755 ants/dist/sample_bots/csharp/compile.sh
mode change 100644 => 100755 ants/dist/starter_bots/coffeescript/MyBot.coffee
mode change 100644 => 100755 ants/dist/starter_bots/coffeescript/ants.coffee
mode change 100644 => 100755 ants/util/block_test.sh
mode change 100644 => 100755 manager/mass_skill_update.py
mode change 100644 => 100755 worker/jailguard.py
mode change 100644 => 100755 worker/release_stale_jails.py
mode change 100644 => 100755 worker/start_worker.sh
Run Code Online (Sandbox Code Playgroud)
我已经尝试更改文件权限,但它不会改变差异结果.
ded*_*dek 310
我在Windows上找到了如何更改权限(也)的解决方案:http://blog.lesc.se/2011/11/how-to-change-file-premissions-in-git.html
例如,以下命令将用户执行权限添加到任意文件:
git update-index --chmod=+x <file>
Run Code Online (Sandbox Code Playgroud)
Cor*_*son 94
来自stackoverflow的另一个问题: 如何让Git忽略文件模式(chmod)的变化?
尝试:
git config core.filemode false
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)core.fileMode If false, the executable bit differences between the index and the working copy are ignored; useful on broken filesystems like FAT. See git-update-index(1). True by default.
Ben*_*hon 28
Git Bash的方便单行:
find . -name '*.sh' | xargs git update-index --chmod=+x
Run Code Online (Sandbox Code Playgroud)
它会将所有.sh文件标记为可执行文件.在那之后,你只需要git commit.
如果您使用Cygwin git(或Linux git,我也认为),您的core.filemode设置很可能已在$ projdir/.git/config中的项目级别设置.我发现我必须执行以下操作才能让我的Cygwin git和我的Windows git在Windows文件系统上很好地共存,而不会出现不存在的文件模式更改:
这允许我的Cygwin git继续查看通常相关的文件模式更改,同时指示Windows git忽略它看到的文件模式更改,这通常是误报.
首先使用以下命令检查文件权限。
git ls-files --stage
Run Code Online (Sandbox Code Playgroud)
然后更改权限。这里“x”代表执行权限。
git update-index --chmod=+x 'scriptname.ext'
Run Code Online (Sandbox Code Playgroud)
现在重新验证权限。
git ls-files --stage
==============================================
如果您使用的是 Windows PC,但部署在 linux 机器上。首先执行以下命令,使其兼容在linux机器上运行
dos2unix 脚本名.ext 脚本名.ext