在Linux上部署的Rails项目中,CRLF线路是否正常? [英] Are CRLF lines ok in a Rails project deployed on Linux?
问题描述
现在我已经转换为git,我看到这个我的许多档案库中的文件包含 CRLF
行结束。我希望这样做一切都是一致的( LF
),而不是以丢失每个文件的编辑历史为代价的代价 CRLF
行结束。
你能想到我无法离开文件的原因吗?我似乎要记住,shell脚本或cron文件有问题,或者没有回复 CRLF
的问题。
另外,我知道所有关于Git选项 core.autocrlf
和 core.safecrlf
,但是有一些方法将所有文本文件从 CRLF
转换为 LF
(在linux端) ... ie core.autolf选项或类似的东西
如果可以重写您的存储库历史记录(请参阅问题重写历史记录)您可以使用git filter-branch将CRLF转换为LF:
git filter-branch --tree-filter'find。 -path'./.git'-prune -o-type f -exec dos2unix \ {} \;'HEAD
请注意,如果您的存储库中有二进制文件,则必须优化find命令以排除它们。
I have a Git repository (originally CVS, then SVN, now Git) containing a Rails project that has been deployed on Linux for a while now. Everything seems to run fine.
Now that I've converted to git, I see that many of my files in the repository contain CRLF
line endings. I'd love for it to all be consistent (LF
), but not at the expense of loosing the edit history of every file that has CRLF
line endings.
Can you think of any reason I can't leave the files as they are? I seem to remember there being a problem with shell scripts or cron files or something that didn't respond to CRLF
very well.
Also, I know all about the Git options core.autocrlf
and core.safecrlf
, But is there some way to have it convert all text files from CRLF
to LF
on checkout (for the linux side) ... i.e. a core.autolf option or something similar?
If it is ok for you to rewrite your repository's history (see problems with rewriting history) you could use git filter-branch to convert CRLF to LF:
git filter-branch --tree-filter 'find . -path './.git' -prune -o -type f -exec dos2unix \{} \;' HEAD
Note that if you have binary files in your repository you will have to refine the find command to exclude them.
这篇关于在Linux上部署的Rails项目中,CRLF线路是否正常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!