In an arbitrary Git project set up locally, a .gitattribute
file can be included in the root directory to control special characters depending on environments (using Apache Spark on GitHub as an example):
*.bat text eol=crlf
*.cmd text eol=crlf
*.java text eol=lf
*.scala text eol=lf
*.xml text eol=lf
*.py text eol=lf
*.R text eol=lf
This file will only be used by Git when commiting new files, which may result in many fragmented commits that don't change file content except special characters (in particular, line separators).
Which Git command can I use to modify all files under a project in one run, regardless of whether it is committed?
As I mentioned with Git 2.16 (Q1 2018), you can apply an updated .gitattributes
directive with the --renormalize
option:
git add --renormalize .
That would apply to all existing files, not just new files.