Android的换行和混帐混帐、换行、Android

2023-09-07 15:55:04 作者:你是我此生不可遇见的海

我即将把Android项目进入一个Git仓库,但我对行结尾有点不确定

I'm about to put a android project into a git repository, but I am a little uncertain about the line endings

我的这个项目目前住在Windows上,所以autocrlf设置为true,但是当我做了最初​​的承诺,我得到以下警告:

My this project currently lives on windows, so autocrlf is set to true, but when I did the initial commit i got the following warnings:

警告:LF将被CRLF在/project/file.name取代 该文件将有原来的行结束在你的工作目录。

warning: LF will be replaced by CRLF in /project/file.name The file will have its original line endings in your working directory.

首先,为什么某些文件LF当我在Windows上:-S?这是因为Android是基于Linux的,并期望他们成为LF,而不是CRLF?其次,为什么它要提交它们的CRLF?我认为这autocrlf真应该检出的窗口,但签入的UNIX?

First, how come certain files are LF when i'm on windows :-S? Is this because android is linux based and expect them to be LF rather than CRLF? Secondly, how come it wants to commit them as CRLF? I thought it "autocrlf true" is supposed to checkout as windows, but check-in as UNIX?

在夏日,我希望能够用我的两个Mac,Linux和Windows机器的工作在这个项目上。最新最好的程序,accomblish呢? (我一直只是用autocrlf输入适用于Mac / Linux和在过去的窗口autocrlf true和我没有任何问题,但是这是我的第一个Android项目,我打算把在GIT,似乎不同的行为)

In summery, I want to be able to use both my mac, linux and windows machines to work on this project. Whats the best procedure to accomblish this? (I always just used "autocrlf input" for mac/linux and "autocrlf true" for windows in the past and I haven't had any issues, but this is my first android project I am going to put in GIT, and it seems to behave differently)

推荐答案

只要不与 autocrlf 打扰:keep它为false 。 另请参见How行结束转换具有不同操作系统的之间混帐core.autocrlf工作。

Simply don't bother with autocrlf: keep it to false. See also "How line ending conversions work with git core.autocrlf between different operating systems".

如果您使用的编辑器不会改变EOLS,可以用LF EOL风格翻过平台完全正常工作。

If you use editors which doesn't change EOLs, you can work entirely with LF eol style accross platform.

如果您FND一些文件,而您的有无以的实施EOL,使用的 gitattribute EOL 的指令。 请参见Distributing与code 混帐配置。

If you fnd some files for which you have to enforce eol, use a gitattribute eol directive. See "Distributing git configuration with the code".