'Confusions in git EOL configuration
My files should have consistent line endings on both system following CRLF and system following LF. This github article explains how to set it up, and this git article explains more details about .gitattributes:
Checking-out and checking-in
These attributes affect how the contents stored in the repository are copied to the working tree files (...)
text
This attribute enables and controls end-of-line normalization. When a text file is normalized, its line endings are converted to LF in the repository. (...)
Set to string value "auto"
When text is set to "auto", the path is marked for automatic end-of-line conversion. If Git decides that the content is text, its line endings are converted to LF on checkin. When the file has been committed with CRLF, no conversion is done.
I understand that git will convert line endings of text files into LF as the result of the normalization when it check-in(store into the repo).
Questions
- What does
When the file has been committed with CRLF, no conversion is donemean? Does it mean that git will not convert the line endings ofjsfiles intoLFif I have following.gitattributes? (or maybe it will make sure they areCRLF)
*.js text eol=crlf
- Why does the example of the first article have following setting in
.gitattributes? Wouldn't git just handle files as it used to do that doesn't match any pattern in.gitattributes?
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
- Wouldn't above setting lead us to define additional settings like following one so git won't
normalizesuch files that shouldn't be modified? (because* text=autowould make git treat every file astext)
# Denote all files that are truly binary and should not be modified.
*.png binary
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
