如何使`git diff`与StackExchange diff一样细? [英] How can I make `git diff` as fine-grained as StackExchange diff?

查看:88
本文介绍了如何使`git diff`与StackExchange diff一样细?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个差异工具可以突出显示单个字符的编辑内容,而不仅仅是显示整行的旧版本和新版本(即,差异StackExchange向您显示的是对帖子的编辑)?



我希望我可以在Linux命令行上以 git diff 使用c $ c>。

解决方案

您可以尝试从,该文章位于您应该了解的30个Git CLI选项克里斯托弗·波特内努夫(Christophe Porteneuve)。


Is there a diff tool which can highlight single character edits as such, and not just show the old and new version of the whole line (i.e. the kind of diff StackExchange shows you for edits to a post)?

I'd prefer one I could use on the Linux command line as diff in git.

解决方案

You can try, from git diff:

git diff --color-word=.

Which is equivalent to --word-diff=color plus (if a regex was specified) --word-diff-regex=<regex>.

That would transform this git diff:

into this one:

Images are from the section "Produce more useful diffs" of the article "30 Git CLI options you should know about" written in Sept. 2014 by Christophe Porteneuve.

这篇关于如何使`git diff`与StackExchange diff一样细?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆