34
7
I need to diff two files (not two versions of the same file, they are however tracked by git, but that is unrelated) and I would like some colored output, how can I achieve that?
$ diff file_1 file_2
1,9d0
< <script ... >
< // more code
< </script>
$
Above code shows me the difference between those files, however without any colors. For longer diffs that is hard to read.
Alternatively, is there a way for git (with which I do have nice color output) to diff two different files (not changes to a file)?
OSX (10.7.5)
6yay for git diff – chrismarx – 2015-02-04T19:33:24.133
8
git diff
should be at the top of your answer! +1 for pointing out that it works even outside of a repository. – Lucio Paiva – 2015-02-07T18:26:17.3074'git diff' does not work on generic files so aliasing diff to be 'git diff' can be harmful – Anton Chikin – 2015-04-23T23:13:19.097
1This doesn't work for me...
echo one > foo; echo two > bar; git diff foo bar
produces no output, whilediff foo bar
produces `1c1< one
` (with proper formatting, of course) – LarsR – 2016-11-23T08:04:13.427
git diff
doesn't work for e.g. pipes – Piotr Findeisen – 2018-01-24T15:49:03.197