How can I visualize per-character differences in a unified diff file?

后端 未结 7 1935
庸人自扰
庸人自扰 2020-11-30 17:13

Say I get a patch created with git format-patch. The file is basically a unified diff with some metadata. If I open the file in Vim, I can see which lines have

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 17:55

    If you have nothing against installing NodeJS, there's a package called "diff-so-fancy" (https://github.com/so-fancy/diff-so-fancy), which is very easy to install and works perfectly:

    npm install -g diff-so-fancy
    git diff --color | diff-so-fancy | less -R
    

    Edit: Just found out it's actually a wrapper for the official diff-highlight... At least it's easier to install for perlophobes like me and the GitHub page is nicely documented :)

提交回复
热议问题