Carriage return
How Carriage return works
Carriage Return (CR) is ASCII code 13. The name comes from typewriters, where returning the carriage to the left margin was a separate mechanical action from advancing the paper (the line feed).
This two-step legacy created the longest-running compatibility headache in computing. Windows uses CR+LF (\r\n) to end lines. Unix, Linux, and macOS (since OS X in 2001) use LF alone (\n). Classic Mac OS (pre-2001) used CR alone (\r). When you open a Windows text file on Linux, extra \r characters can appear as ^M at line ends. Git's
This two-step legacy created the longest-running compatibility headache in computing. Windows uses CR+LF (\r\n) to end lines. Unix, Linux, and macOS (since OS X in 2001) use LF alone (\n). Classic Mac OS (pre-2001) used CR alone (\r). When you open a Windows text file on Linux, extra \r characters can appear as ^M at line ends. Git's
core.autocrlf setting exists specifically to handle this. See other control characters and their codes on the ASCII table.