Add .gitattributes and renormalize EOL in text files. #614
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes resolve nonnormalized line endings (CRLF) in the git index. The CRLF endings in the index are incompatible with many git configurations and interfere with git commands (e.g. cannot change branches without force). If the git index line endings are normalized as LF, git clients can choose LF or CRLF for local worktrees.
Note
To find the nonnormalized files with CRLF in the git index.
There are two steps to normalize the line endings:
.gitattributesfile to specify text files to normalize.For step (1), we add an entry in
.gitattributesfor each file extension in the repository. To protect binary files (images, assemblies, etc.) from corruption during line ending normalization, we assign thebinaryattribute to the relevant extensions. The remaining files are text files with thetextattribute eligible for line ending normalization. As a starting point, the entries provided are conservative (i.e. avoids opinions on style).Note
To find the unique file extensions in the repository (excluding .gitignore files).
For step (2), we run a git command to renormalize any nonnormalized files in the git index:
Aside from the file
.gitattributes, all other file changes reflect changes in line endings.After these changes, all text files in the git index should be normalized. To verify, the following git command should have no output: