Information Technology Reference
In-Depth Information
13-7. Defining line endings for individual
files and directories
Problem
You start a new project. You want to configure it in such a way that:
• Text files stored under the linux/ directory always use LF line endings.
• Text files stored under the windows/ directory always use CRLF line
endings.
• Text files stored under the mixed/ directory are never converted—they
always preserve the original line endings.
Solution
Initialize a new repository:
$ cd git-recipes
$ git init 13-07
$ cd 13-07
Create the directories and files:
$ mkdir linux
$ mkdir mixed
$ mkdir windows
$ printf "linux \n a \n b \n c \n d" > linux/abcd.txt
$ printf "mixed \n a \r\n b \n c \r\n d" > mixed/abcd.txt
$ printf "windows \r\n a \r\n b \r\n c \r\n d" > windows/
abcd.txt
Next create the .gitattributes file with the following contents:
Search WWH ::




Custom Search