Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
`git状态和下线检测_Git_Newline - Fatal编程技术网

`git状态和下线检测

`git状态和下线检测,git,newline,Git,Newline,当我查看git状态时,我看到: Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: project/schema-readme.md

当我查看git状态时,我看到:

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   project/schema-readme.md
        modified:   project/vp-automate.php
这意味着当提交时,Git将实际更新它们,使其具有LF行结尾。这就是为什么
git status
将这些文件标记为“已修改”的原因,即使它们当前未被修改


编辑:这很奇怪,在我的项目中有更多的文件使用CRLF行结尾,并且没有检测到被修改。。我不明白
schema readme.md
vp automation.php
有什么特别之处,以至于Git检测到它们被修改。

请尝试配置core.autocrlf属性。它主要用于Windows计算机上,以确保本地文件使用CRLF作为行尾(因此它们可以在记事本等中工作),而存储库中的文件则使用“适当的”LF结尾

从文档(git config--help)中:


另请参见-正如建议的那样,在linux上,您应该将其配置为“输入”。

Git根据SHA1校验和之外的一些文件属性检测已更改的文件,这可能导致这两个文件被标记为已更改。有关Git如何检测文件更改的更多信息,请参阅。

问题是我不想要CRLF-出于各种原因,我们甚至在Windows上也需要LF。问题仅仅在于为什么Git会检测到一些未更改的文件被更改,以及它是否与行尾有关。
* text=auto eol=lf
   core.autocrlf
       Setting this variable to "true" is almost the same as setting the text attribute to "auto" on all files except that text files are not guaranteed to be normalized: files that contain CRLF in the repository will not be touched. Use this setting if you want to have CRLF line endings in
       your working directory even though the repository does not have normalized line endings. This variable can be set to input, in which case no output conversion is performed.