Handling LF and CRLF Line Endings
On this page:
- Basics
- Enabling smart handling of LF and CRLF line separators
- Handling the problems with line separators during commit
Basics
Quite often people working in a team and using the same repository or upstream prefer different operating systems. This may result in problems with line endings, becauseUnix,Linux, and macOS use LF
and Windows uses CRLF
to denote the end of a line. AppCode shows the discrepancies in line endings in theDifference Viewer Dialog, so you can fix them manually.
To have Git solve such problems automatically, you need to set the core.autocrlf
attribute to true
on Windows and to input
on Linux and macOS. For more details on the meaning of the core.autocrlf
attribute, see the article Mind the End of Your Line orDealing with Line Endings. You can change the configuration manually by running git config --global core.autocrlf true
on Windows or git config --global core.autocrlf input
on Linux and macOS. However, AppCode can analyze your configuration, warn you if you are about to commit CRLF
into the repository, and offer to set the core.autocrlf
setting to true
or input
depending on the operating system used.
Enabling smart handling of LF and CRLF line separators
To enable smart handling of LF and CRLF line separators
To enable smart handling of LF
and CRLF
line separators
- Open the Preferences dialog box.
- Under the Version Control node, clickGit.
- On the Git page that opens, select the Warn if CRLF line separators are about to be committed checkbox.
Handling the problems with line separators during commit
To handle problems with the line separators during commit
- Enable smart handling of LF and CRLF line separators. After that, AppCode will show the Line Separators Warning Dialog every time you attempt to commit a file with
CRLF
separators, unless you have set any related git attributes on the affected file. In the latter case, AppCode supposes that you clearly understand what you are doing and excludes the file from analysis. - When the Line Separators Warning Dialog is displayed, do one of the following:
- To ignore the warning and commit the file with
CRLF
separators, click the Commit As Is button. - To have the
core.autocrlf
attribute set totrue
orinput
depending on the operating system used before commit, click the Fix and Commit button. As a result, all theCRLF
separators will be replaced withLF
separators and committed into the repository. Note that the reverse operation will not be performed when you download the files into your working directory, that is, noCRLF
will appear in place ofLF
. - To stop the commit procedure, clickCancel.
- To ignore the warning and commit the file with
- To suppress showing the dialog box in the future, select the Don't warn again check box.