Add .gitattributes To Your IaC Repos
Adding a .gitattributes file to your git repo can easily let WIndows and other users collaborate without newline problems.
Have a team that mixes Windows users and macOS/Linux users?
Sometimes I see commits where the whitespaces changes make it impossible to see what actually changed. Many times, this is because a Windows user has touched a file and made it CRLF
instead of LF
.
You can force gently correct them to use the correct-on-the-Internet LF
by having the following file in your git repo:
a .gitattributes
file with the following contents:
# Declare files that will always have LF line endings on checkout.
*.tf text eol=lf
*.yml text eol=lf
*.json text eol=lf
Now all your files will be LF!
For more information on using .gitattributes
, check out the docs.