git diff reporting mode changes after moving the repository
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.
You can apply this setting
git config core.filemode false
causing git to ignore differences in file-mode.
This solution was found in @kan's answer to another question
链接地址: http://www.djcxy.com/p/30028.html