我很确定我理解文件末尾没有换行符的含义。我想提供一个我很久以前创建并重新设置的分支的拉取请求(提交可能来自之前.gitattributes
添加的时间)。我看到一些.java
源代码文件只有变化
-}
\ No newline at end of file
+}
无论配置如何,我都希望将这些更改从 PR 提交中排除。我想避免选择更改git difftool
并扩大我对git
.
问题是我已经不明白这种变化是如何存在的,因为有一个.gitattributes
with
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
*.java text
*.css text
*.js text
*.xml text
*.dtd text
*.xsl text
*.properties text
*.txt text
*.svg text
*.yml text
*.md text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.gif binary
*.jpg binary
*.jpeg binary
*.eot binary
*.ttf binary
*.woff binary
*.woff2 binary
在存储库中,我运行git rm --cached -r . && git add .
了应该将所有行尾转换为 LF 因为*.java text
(也尝试过*.java text
),但是没有显示任何更改(反对HEAD
)并且git diff
仍然显示行尾差异。
也find ./ -type f -name '*.java' -exec dos2unix {} \;
不会导致任何更改被识别git status
并git diff master
仍然显示行结束更改(而工作目录没有暂存或未暂存的更改)。
我对隐藏更改不感兴趣,就像git diff --ignore-all-space
会做的那样。
我git
在 Ubuntu 18.04 上使用 2.17.1。