如何让git不改变一个特定文件的行结束符? [英] how to make git not change line endings for one particular file?

查看:90
本文介绍了如何让git不改变一个特定文件的行结束符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Microsoft Visual Studio中的功能,.sln文件必须具有Windows样式行结尾,以便Windows资源管理器可以在Visual Studio中打开它们。所以我需要能够完整地提交这个特定文件的行尾。如果所有其他文件都被转换,那就好了。问题是如何让git只接受一个带有windows结尾的单个文件?

解决方案

看一看 gitatttributes 文档。使用最新版本的git,您可以为文件设置 eol 属性,以控制在检出文件时将使用哪些行尾。



您应该可以在存储库中创建 .gitattributes 文件,其格式如下所示:

  path / to / my / file eol = crlf 


due to a "feature" in Microsoft's Visual Studio, .sln files must have windows style line endings so that the windows explorer could open them in Visual studio. So I need to be able to commit this one particular file with line endings intact. It is fine if all other files get converted. The question is how to make git accept just one single file with windows endings?

解决方案

Take a look at the gitatttributes documentation. With recent versions of git, you can set the eol attribute for files to control what end-of-lines will be used when the file is checked out.

You should be able to create a .gitattributes file in your repository that looking something like:

path/to/my/file eol=crlf

这篇关于如何让git不改变一个特定文件的行结束符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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