git忽略行尾 [英] git ignore line endings

查看:238
本文介绍了git忽略行尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有人问过类似的问题,但是我仍然无法解决它.

I know that similar questions have been asked, but I still can't get it working.

我的项目在使用不同操作系统的人们之间共享,并且我在OSX上.而且,并不是每个人都使用git,有时我最终不得不提交其他人的更改.

My project is shared among people using different operating systems, and I'm on OSX. Also, not everyone uses git yet and I end up sometimes having to commit changes of others.

有时,git总是无所适从地表示有未决的更改.查看它们看起来相同的文件:

Sometimes, out of nowhere git says there are pending changes. Looking at the files they look identical:

@@ -1,6 +1,6 @@
-<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
->
-    <Deployment.Parts>
-    </Deployment.Parts>
-</Deployment>
+<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+>
+    <Deployment.Parts>
+    </Deployment.Parts>
+</Deployment>

我怀疑这是行尾问题.

[edit]一个外部差异工具专门说:状态:1个不同行的结尾不同-左:Windows(CRLF),右:Unix(LF)"

[edit] One external diff tool specifically says: "status: 1 difference Line endings differ - left: Windows (CRLF), right: Unix (LF)"

按照一些在线提示,我的配置如下:

Following some of the online tips, my configuration looks like:

[core]
    excludesfile = /Users/nathanh/.gitignore_global
    autocrlf = input
    attributesfile = /Users/nathanh/.config/git/attributes
    whitespace = cr-at-eol

还有我的属性文件:

# Ignore all differences in line endings
*        -crlf

为什么仍然显示文件已被修改?

Why is it still showing me that the files are modified?

推荐答案

从JetBrains.com阅读

Read this from JetBrains.com

要让Git自动解决此类问题,您需要在Windows上将core.autocrlf属性设置为true,在Linux和OS X上进行输入.有关core.autocrlf属性含义的更多详细信息,请参见文章注意行尾或处理行尾.您可以通过运行

To have Git solve such problems automatically, you need to set the core.autocrlf attribute to true on Windows and to input on Linux and OS X. For more details on the meaning of the core.autocrlf attribute, see the article Mind the End of Your Line orDealing with Line Endings. You can change the configuration manually by running

git config --global core.autocrlf true 

在Windows或

git config --global core.autocrlf input 

在Linux和OS X上

.但是,IntelliJ IDEA可以分析您的配置,警告您是否要将CRLF提交到存储库中,并可以根据所使用的操作系统将core.autocrlf设置设置为true或输入.

on Linux and OS X. However, IntelliJ IDEA can analyze your configuration, warn you if you are about to commit CRLF into the repository, and offer to set the core.autocrlf setting to true or input depending on the operating system used.

希望这可以阐明问题所在.

Hopefully this might shed some light on the problem.

这篇关于git忽略行尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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