Information Technology Reference
In-Depth Information
13-6. Unintended conversion of all line
endings
Problem
You want to learn how to avoid unintentional conversion of all line endings in an open-
source project. To gain a deeper understanding of this problem you want to reproduce
tps://github.com/hakimel/reveal.js
and then to change the repository
configuration in such a way that git will consider all the files changed.
Solution
Set the global git configuration to perform
LF=>CRLF
conversion during checkout and
CRLF=>LF
conversion during check-in:
$ git config --global core.autocrlf true
Then clone the
reveal.js
repository:
$ cd git-recipes
$ git clone
https://github.com/hakimel/reveal.js.git
13-06
$ cd 13-06
Right after the clone command, all the text files in
13-06
directory will use
CRLF
line endings. This encoding will be used regardless of your operating system.
CRLF
will be used in Windows, Linux, and MacOS. The repository is in clean state—you can
verify it with
$ git status -sb
.
Now, turn off all conversions of line endings with:
$ git config --global core.autocrlf false
and recreate the staging area with:
$ rm .git/index
$ git reset