开发者

command line recursive word-based diff?

开发者 https://www.devze.com 2023-02-10 08:02 出处:网络
is there a command line program that gi开发者_JAVA百科ves recursive word-based diff (on 2 directories)?

is there a command line program that gi开发者_JAVA百科ves recursive word-based diff (on 2 directories)?

diff -u is recursive, but it doesn't do word by word comparison. wdiff and dwdiff does word based diff but there are not built-in options for recursive diff.

I would like to pipe the result to colordiff so a program that generates output that colordiff understands would be especially useful. Any suggestions? Thanks!

CC


Git can do it and output color:

The following often works:

git diff --color-words path1 path2

but in general you may need to do

git diff --no-index --color-words path1 path2

Neither file even needs to be in a git repository!

--no-index is needed if you and the paths are in a git working tree. It can be elided if you or one of the files are outside a git working tree.

Manpage: https://git-scm.com/docs/git-diff/1.8.5 (and later...)

git diff --no-index [--options] [--] […​]

This form is to compare the given two paths on the filesystem. You can omit the --no-index option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git.

0

精彩评论

暂无评论...
验证码 换一张
取 消