整个目录树(Git)的换行结束 [英] Convert line-endings for whole directory tree (Git)

查看:84
本文介绍了整个目录树(Git)的换行结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下情况:

我正在使用运行OS X的Mac,并且最近加入了一个项目,其成员目前都使用Windows。我的第一个任务之一是在Git存储库中设置代码库,所以我从FTP中取出了目录树,并试图将它检入我在本地准备的Git仓库中。尝试这样做时,我所得到的仅仅是

 致命:在blog / license.txt中CRLF将被替换为LF。 

由于这会影响blog文件夹下的所有文件,因此我正在寻找一种方便的方式将树中的所有文件转换为Unix行尾。有没有一种工具可以开箱即用,或者我可以自己编写脚本?



作为参考,我的Git配置涉及到行尾:

  core.safecrlf = true 
core.autocrlf =输入


解决方案

dos2unix 可以做到这一点您。相当简单的过程。

dos2unix文件名



感谢toolbear,这里有一个-liner递归地替换行结尾并正确处理空格,引号和shell元字符。



find ./ -type f -exec dos2unix {如果您使用的是dos2unix 6.0,则二进制文件将被忽略。


Following situation:

I'm working on a Mac running OS X and recently joined a project whose members so far all use Windows. One of my first tasks was to set up the codebase in a Git repository, so I pulled the directory tree from FTP and tried to check it into the Git repo I had prepared locally. When trying to do this, all I got was this

fatal: CRLF would be replaced by LF in blog/license.txt.

Since this affects all files below the "blog" folder, I'm looking for a way to conveniently convert ALL files in the tree to Unix line-endings. Is there a tool that does that out of the box or do I get scripting something myself?

For reference, my Git config concerning line-endings:

core.safecrlf=true
core.autocrlf=input

解决方案

dos2unix does that for you. Fairly straight forward process.
dos2unix filename

Thanks to toolbear, here is a one-liner that recursively replaces line endings and properly handles whitespace, quotes, and shell meta chars.

find ./ -type f -exec dos2unix {} \;

If you're using dos2unix 6.0 binary files will be ignored.

这篇关于整个目录树(Git)的换行结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆