Git CRLF changes showing up in git status

前端 未结 2 1676
遇见更好的自我
遇见更好的自我 2021-01-13 15:35

I know there are a ton of questions/answers similar to this one, however I could not find a specific answer to this problem. We are a .net shop and are using git.

I

2条回答
  •  攒了一身酷
    2021-01-13 15:59

    You cannot ignore types of filechanges for git status. You can use .gitignore to ignore entire files. And you can use the various whitespace options to transform what is committed, what is highlighted (in red) or shown at all in the diff and commit views.

    The reasons you cannot ignore these filechanges are:

    • Tracking filechanges is the entire point of version control.
    • Git represents file contents independent of path by using a SHA1 hash of the contents. Your ^M affects that SHA1 so that makes it unavoidably significant.

    In short, you probably need to fix your other processes or develop clean-up post-processes. Alternatively you could use:

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

    This is not a perfect analogue of status proper, but it might be enough for your needs. For convenience, you can even build a git-alias'd "statusx" command by adding to your .gitconfig:

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

    There are some additional whitespace options if that proves inadequate: --ignore-space-change and --ignore-all-space. See git diff --help for more detail.

提交回复
热议问题