Configuring line endings treatment
There are things about text files that normal people aren't even aware of. For starters, any character in a text file is represented as a set of numbers when saved on your hard drive. A line break, the thing that you see after you hit the Enter key, is technically also a character, and thus also represented as a number. However, through the years, operating systems such as Windows, Linux or macOS have been representing the line break in files as different numbers.
To this day it remains a source of confusion. Say, you created a file on Linux and sent it to your friend, who uses Windows. All they see is a solid wall of text, because Windows doesn't recognize Linux's line breaks.
When it comes to Git, this problem becomes critical, because multiple people may work on the same files, using different operating systems. The most common workaround is to let people work with their files as usual, but when saving to a repository, make all line endings uniform (e.g. Linux-like).
If you really want to understand what's going on with these settings, it's always better to read the documentation on core.autocrlf
and core.safecrlf
.
Please follow the instructions below, depending on your operating system. You're using Linux.
The --global
option sets the default Git settings used in repositories on your computer. However, these values can be overridden per repository—just run the needed git config
without the --global
option while being in the repository you want to adjust.
Set your line ending treatment configuration.
Hi! I'm Alex, creator of GitByBit.
This page is a part of the interactive course about Git version control.
It's a one-of-a-kind course that is integrated into the VS Code code editor. Learning directly in VS Code lets you operate Git exactly as you would in real life, doing real jobs, writing real code.
In addition, the course has access to your actual terminal, so it can point out mistakes, suggest workarounds, etc.
The course is FREE, there are no Ads or other bullshit. There are optional premium add-ons you can purchase, mainly to support my work (regrettably, I have to eat every day), but that's totally up to you.