如何更改git status的行为,以显示最终未提交的已修改文件?

8
我在一个仅限于Windows的工作环境中工作,开发人员使用各种工具来编辑他们的文件。我们使用.git以及Atlassian堆栈来对我们的代码进行版本控制。我几乎喜欢所有的东西。
我最近刚刚完成了一场漫长而艰苦的斗争,试图理解git如何解释行尾和core.autocrlf的原因。我们决定使用core.autocrlf true,现在一切都差不多了。
我想知道如何更改git status的这种行为,真是太好了。
  • I have a file with CRLF line endings.
  • I change the line endings to LF

    $ git status
    On branch somebranch
    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:   Src/the_file_i_changed_to_LF.js
    
  • But then...

    $ git commit -a
    warning: LF will be replaced by CRLF in Src/the_file_i_changed_to_LF.js.
    The file will have its original line endings in your working directory.
    On branch somebranch
    nothing to commit, working directory clean
    

转化为这个:

  • I have a file with CRLF line endings.
  • I change the line endings to LF

    $ git status
    On branch somebranch
    nothing to commit, working directory clean
    
  • which makes sense since nothing will get committed anyway.

这可能吗?

我认为可能的重复并没有提供我所寻找的答案。我想强调,我知道我的设置core.autocrlf true是什么,并希望保持这种状态。我感兴趣的是要么不检测git status中不会提交的更改,要么理解为什么这不可能。

1个回答

1
当你设置core.autocrlf true时,工作目录中的所有文件将具有CRLF行尾(不考虑存储库中实际行尾的情况)。对于大多数Windows用户来说,这已经足够好了。
从你的问题中我理解到你想要使用LF来处理你的工作目录文件(即本地文件)。因此,在这里你应该使用core.autocrlf input。这将给你与存储库中完全相同的行尾(但仍然会确保所有检入都是用LF进行的)。
在这个answer中阅读更多关于true、false、input之间差异的内容。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接