Using Git Diff as Diff Replacement
You can use git diff instead of the normal unix/linux/gnu diff.
Advantages of using git diff:
- Has color option.
- Gives unified diff result by default. (in GNU diff, you have to use the option
- on Microsoft Windows, you probably have git installed but not unix diff.
Using Git for Diff
git diff --color --no-pager --no-index file1 file2
show differences between files, ignore git index (staged) file.
If the files are outside any git repository, then
--no-indexis not necessary.
By default, it output one page at a time.
Color and no pager can be turned on globally. See git config
2013-06-14 big thanks to Yuri Khan on using git diff.