使 git diff (不是 difftool)和 git log -p 与 *.sql 文件和 Windows PowerShell 一起使用
我知道如何配置外部工具来通过调用 git difftool 来查看差异。但是,如果我想将文件的整个历史记录的所有更改“转储”到控制台窗口,我想使用 git log -pdifftool
(使用我配置的工具)正确处理 unicode 文件,但是 diff
没有,这就是我认为 git log -p
在幕后使用。
有没有办法让 git diff 与给定/配置的扩展名的文件一起工作,我知道实际上只有 ANSI 字符并显示输出到控制台的实际文本更改(在我的例子中是 Windows PowerShell)托管在控制台内)。
注意:我看过 这个问题/答案关于让 git diff 识别 UTF16,但我无法让它工作(我的系统上不存在 iconv 和 mktemp)。
也许这是我应该继续检查/试验的方法,作为唯一可能的解决方案?或者我唯一的解决方案是确保我知道仅存在 ANSI 字符的文件保存为 ANSI - 如果丢失我当前在 *.sql 文件(以及我不知道的任何其他文件)上拥有的所有历史记录,将会令人失望现在存储为 unicode - 我是 Visual SourceSafe 新转换的 git 用户,因此不必查看我修改的所有文件类型的差异)。
I know how to configure an external tool to view differences with a call to git difftool
. However, if I want to see an 'dump' of all changes for entire history of a file to my console window, I wanted to use git log -p <filename>
. The problem I'm having is with *.sql files in my Windows environment. difftool
(using my my configured tool) correctly handles the unicode file, however diff
does not, which is what I think git log -p
uses under the hood.
Is there a way to make git diff
'work' with files of a given/configured extension where I know there is truly only ANSI characters and show actual text changes outputted to the console (in my case Windows PowerShell hosted inside Console).
Note: I've looked at this question/answer about making git diff recognize UTF16, but I couldn't get it to work (both iconv and mktemp were not present on my system).
Maybe this is the approach I should continue to examine/experiment with as the only possible solution? Or is my only solution is to ensure files where I know only ANSI characters are present are saved as ANSI - would be disappointing to lose all the history I currently have on *.sql files (and any other files I'm not aware of that are stored as unicode right now - I'm a newly converted git user from Visual SourceSafe, so haven't had to view differences on all my file types that I modify yet).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下 git 属性。您可以自定义 diff 和其他方面处理某些文件的方式。
这有什么帮助
Take a look at git attributes. You can customize how certain files are handled by diff and other aspects.
How this helps