Git 2.16 introduces two new interesting options for dealing with line endings.
The first is the new
--ignore-cr-at-eol
option to
git diff
, which ignores changes in line endings in a diff, which otherwise sometimes lead to it appear that the entire file has changed (which, in a sense, it has).
git diff --cached --ignore-cr-at-eol
The second is the new
--renormalize
option to
git add
.
git add --renormalize .
To quote the man pages,
git add --renormalize
"is a new and safer way to record the fact that you are correcting the end-of-line convention and other "convert_to_git()" glitches in the in-repository data."
So the way to normalize line endings in a repository has been revised to the following:
echo "* text=auto" >.gitattributes
git add --renormalize .
git status # Show files that will be normalized
git commit -m "Introduce end-of-line normalization"
Note that the old way:
...
git read-tree --empty # Clean index, force re-scan of working directory
git add .
...
will cause Git to delete files from the repository that are included in
.gitignore
.
That might be a good thing for certain "undisciplined" repositories.