Git CRLF Changes Displayed in Git Status

I know that there are a ton of questions / answers like this, however I could not find a concrete answer to this problem. We are a .net store and use git.

I would like to ignore CRLF (^ M) changes in files when executing git state. During development, other processes sometimes modify files and enter CRLFs, which ultimately leads to them appearing as modified when git status is executed. I have the line "* text = auto" in my .gitattributes file to normalize line endings in checkout / commit, but this is not what I'm looking for. I also tried adding the following to the git configuration (core.whitespace = cr-at-eol), but they still appear as modified.

How to tell git to ignore all changes in CRLF (^ M)?

+4
source share
2 answers

You cannot ignore file types for git status. You can use .gitignore to ignore whole files. And you can use various space options to convert what was fixed, what is highlighted (in red) or generally shown in diff and commit views.

Reasons why you cannot ignore these changes:

  • Tracking file changes is a whole point of version control.
  • Git represents the contents of the file regardless of the path using the SHA1 hash of the contents. Your ^ M affects SHA1, which makes it inevitable.

, , , . :

git diff-files --name-status --ignore-space-at-eol

, . git-alias 'd statusx ", .gitconfig:

[alias]
    statusx = diff-files --name-status --ignore-space-at-eol

, : --ignore-space-change --ignore-all-space. . git diff --help.

+3

-crlf .gitattributes:

*.cs -crlf

.gitattributes man page -text, ( diff).

core.eol eol.
core.autocrlf, .

0

Source: https://habr.com/ru/post/1544226/


All Articles