Android Studio - CRLF vs LF for a Git-based multi-platform project

I am working on an Android project involving several developers, some of which are on Windows, others Linux / MacOS. Since I'm on Windows, I was asked to configure Git as follows to avoid problems:

autocrlf = true
safecrlf = true

This works mostly fine. All .java / XML / etc files that I create in Android Studio are in CRLF, convert to LF when I paste them into the repo, and then return to CRLF when I make changes to my local copy. The problem is that some file types, such as vector available resources, are generated in LF, for some reason. Therefore, when I try to add them to Git, I get an "irreversible conversion" error:

enter image description here I know what I could install safecrlf = warn, but from what I understand, this carries the risk of corrupting binary files if Git mistakenly mistook them for text files, so I'm looking for a safer solution. At the moment, I manually edit vector assets in CRLF before adding them to Git, which avoids the above error message, but requires a tedious repetition of the process for each file. Any way to get Android Studio to generate all local files in CRLF?

+4
source share
1 answer

I would not set core.autocrlfto true(I advise against it since 2010 ): leave it to false.

, , .gitattribtes , Git 2.10. .

echo "*.java text=auto eol=crlf" >.gitattributes

,

$ git config core.autocrlf true

.gitattributes eol , , , repo.
. "" ".

+3

Source: https://habr.com/ru/post/1681031/


All Articles