问题描述
执行git difftool --dir-diff
后,由于某些原因修改了我的工作区文件.我一直猜测它正在转换crlf
和lf
等之间的行尾.但是,做"git config core.autocrlf false
或" git config --global core.autocrlf false
并没有什么区别.我尝试同时使用windiff和作为自定义差异工具无法比较,但是它无济于事,这很糟糕,因为每次我查看.csproj文件中的某些更改时,都会重新加载该项目,因为它说该文件已在外部进行了修改.有什么想法吗?
After doing git difftool --dir-diff
, my workspace files are modified for some reason. I've been guessing that it's converting the line endings between crlf
and lf
etc... However, doing "git config core.autocrlf false
" or "git config --global core.autocrlf false
" don't make any difference. I have tried using both windiff and beyond compare as the custom diff tool but it doesn't help. This is bad since every time I view some changes in my .csproj file, the project is reloaded since it said the file has been modified externally. Any ideas?
推荐答案
可以声明自动转换的唯一其他方法是通过 .gitattributes
文件(请参阅 gitattributes
):
The only other way an automatic conversion can be declared is through .gitattributes
file (see gitattributes
):
- 带有类似
*.txt eol=lf
的指令(" Git:将所有文本文件默认为Unix换行符")或("在git repo和工作副本中强制执行LF eol ") - 带有内容过滤器(涂抹脚本)
- with directives like
*.txt eol=lf
("Git: Default all text files to unix line breaks") or* text=auto
("Force LF eol in git repo and working copy") - with content filter (smudge script)
这篇关于在执行git difftool --dir-diff后,出于某种原因修改了文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!