移动存储库后,git diff报告模式发生变化 [英] git diff reporting mode changes after moving the repository

查看:137
本文介绍了移动存储库后,git diff报告模式发生变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过复制到外部硬盘驱动器,我将一堆git存储库移到了另一个操作系统。现在,当我执行 git diff 时,它会报告所有文件模式已更改。

  diff --git a / .gitignore b / .gitignore 
旧模式100644
新模式100755
diff --git a / .npmignore b / .npmignore
old模式100644
新模式100755
diff --git a / .travis.yml b / .travis.yml
旧模式100644
新模式100755
diff - git a / LICENSE b / LICENSE
旧模式100644
新模式100755
diff --git a / README.md b / README.md
旧模式100644
新模式100755

我对文件权限并不十分了解,我该怎么做这是什么?



提交模式更改?将模式更改为所有非可执行文件? git reset?

解决方案

可能您的外部硬盘驱动器上有不同的文件系统,并不尊重原始文件权限。我只是在提交之前手动纠正它们。



例如,在USB拇指驱动器上常用的FAT32不支持执行权限。将文件从FAT32文件系统复制到普通的类Unix文件系统时,它通常会为所有文件设置执行权限,因为这对文件关闭的伤害要小。



如果您想保留这种信息,请勿将这些文件直接复制到驱动器;相反,制作一个tar文件(可选压缩),然后在另一端解压缩它。 tar格式确实记录了Unix权限位。



请注意,git本身并不追踪可执行文件和非可执行文件。如果模式更改是唯一的区别,并且您不想重新复制所有内容,则可以将 git diff 的输出转换为脚本执行 chmod -x 所有受影响的文件。


I moved a bunch of my git repositories to another OS by copying to an external hard drive. And now when I do git diff it reports all the files modes have changed.

diff --git a/.gitignore b/.gitignore
old mode 100644
new mode 100755
diff --git a/.npmignore b/.npmignore
old mode 100644
new mode 100755
diff --git a/.travis.yml b/.travis.yml
old mode 100644
new mode 100755
diff --git a/LICENSE b/LICENSE
old mode 100644
new mode 100755
diff --git a/README.md b/README.md
old mode 100644
new mode 100755

I don't really know much about file permissions, what am I supposed to do about this?

Commit the mode changes? Change the mode back for all non-executable files? git reset?

解决方案

Probably your external hard drive had a different filesystem on it that didn't respect the original file permissions. I'd just correct them by hand before committing.

For example, FAT32, which is commonly used on USB thumb drives, doesn't support execute permissions. When you copy a file from a FAT32 filesystem to a normal Unix-like filesystem, it typically sets execute permission for all files, since that's less damaging than turning it off for all files.

If you want to retain that kind of information, don't copy the files directly to the drive; instead, make a tar file (optionally compressed) and then unpack it on the other end. The tar format does keep track of Unix permission bits.

Note that git itself doesn't keep track of more than executable vs. non-executable. If the mode changes are the only difference, and you don't want to re-copy everything, you can turn the output of git diff into a script does a chmod -x on all the affected files.

这篇关于移动存储库后,git diff报告模式发生变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆