How to get diff working like git-diff?

Mzzzzzz picture Mzzzzzz · Feb 1, 2011 · Viewed 44.8k times · Source

I like the output formatting of git diff. The color and the +/- representation of changes between lines is easier to read than GNU diff.

I can run git diff using --no-index flag outside of a git repo and it works fine. However, it appears to be missing the --exclude option for excluding files or subdirectories from a recursive diff.

Is there a way to get the best of both worlds? (color options and +/- format of git diff and --exclude option of GNU diff).

I've experimented with colordiff, but I still prefer the output format of git diff

Answer

jonescb picture jonescb · Feb 1, 2011

I don't know how to do color but this will do the +/- rather than < and >.

diff -u file1 file2