问题
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
.
回答1:
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.
来源:https://stackoverflow.com/questions/28505175/how-can-i-make-git-diff-as-fine-grained-as-stackexchange-diff