我非常确定我理解了文件末尾没有换行符的含义。我想提供一个拉取请求,这是我很久以前创建并重新定位的分支(提交可能来自于在添加.gitattributes
之前的时间)。我发现一些.java
源代码文件只有这种更改。
-}
\ No newline at end of file
+}
无论配置如何,我只想将这些更改从PR提交中排除。我想避免使用
git difftool
选择更改,并加深对git
的理解。问题在于,我已经不明白为什么会有这种变化,因为存在一个带有
.gitattributes
的文件。# 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
所做的那样。我正在Ubuntu 18.04上使用
git
2.17.1。