git忽略行结尾

Nat*_*n H 5 git line-endings

我知道已经提出了类似的问题,但我仍然无法使其发挥作用.

我的项目由使用不同操作系统的人共享,我在OSX上.此外,并非每个人都使用git,我最终有时不得不改变其他人.

有时候,git不知道有没有未决的变化.查看文件看起来相同:

@@ -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>
Run Code Online (Sandbox Code Playgroud)

我怀疑这些是行结束问题.

[编辑]一个外部差异工具具体说:"状态:1差异行结束不同 - 左:Windows(CRLF),右:Unix(LF)"

根据一些在线提示,我的配置如下:

[core]
    excludesfile = /Users/nathanh/.gitignore_global
    autocrlf = input
    attributesfile = /Users/nathanh/.config/git/attributes
    whitespace = cr-at-eol
Run Code Online (Sandbox Code Playgroud)

我的属性文件:

# Ignore all differences in line endings
*        -crlf
Run Code Online (Sandbox Code Playgroud)

为什么它仍然告诉我文件被修改了?

Hex*_*ana 6

从JetBrains.com阅读

要让Git自动解决此类问题,您需要在Windows上将core.autocrlf属性设置为true,并在Linux和OS X上进行输入。有关core.autocrlf属性含义的更多详细信息,请参阅文章“ 注意结尾”。您的线路或线路末端的交易。您可以通过运行手动更改配置

git config --global core.autocrlf true 
Run Code Online (Sandbox Code Playgroud)

在Windows上或

git config --global core.autocrlf input 
Run Code Online (Sandbox Code Playgroud)

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

希望这可以为这个问题提供一些启示。

  • 这也应该让`git diff`平静下来吗?它不适合我,但我是 git 的新手,所以也许我没有做对。 (2认同)