当 Git diff 显示模式更改时,这意味着什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16748160/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does it mean when Git diff shows mode changes?
提问by pedja
I'm trying to view changes for a single file that is unstaged.
我正在尝试查看未暂存的单个文件的更改。
First I use git status
to view all the unstaged changes then for example:
首先,我使用git status
查看所有未暂存的更改,然后例如:
git diff AndroidManifest.xml
But I get this output:
但我得到这个输出:
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
old mode 100755
new mode 100644
What does that mean and how can I view changes for specific file?
这是什么意思,我如何查看特定文件的更改?
采纳答案by krlmlr
Most probably, the contents of this file haven't changed, only the executable bit has been cleared. Try actually changing the file by, say, appending an empty line to it, and see what git diff
outputs.
最有可能的是,这个文件的内容没有改变,只是可执行位被清除了。尝试实际更改文件,例如向其附加一个空行,然后查看git diff
输出结果。
Apart from file contents, Git also records the state of the executable bit for each file. It makes sense on Linux systems if you want scripts to be executable right after checkout. See also the following two related questions:
除了文件内容,Git 还记录了每个文件的可执行位的状态。如果您希望脚本在结帐后立即执行,这在 Linux 系统上是有意义的。另请参阅以下两个相关问题:
How do I make Git ignore file mode (chmod) changes?
How do I remove files saying "old mode 100755 new mode 100644" from unstaged changes in Git?
回答by Polygnome
It means that the file mode changed from 755 to 644, but the contents were not altered.
这意味着文件模式从 755 更改为 644,但内容没有改变。
git diff
is exactly what you are looking for - it shows the changes from unstaged files to the last commit. git diff --cached
is for staged files.
git diff
正是您正在寻找的 - 它显示了从未暂存文件到最后一次提交的更改。git diff --cached
用于暂存文件。