Git diff output to file preserve coloring

Is it possible to do git diff and save the output to a file with the coloring somehow?

I know how to do git diff > filename.rtf - which saves to a file, but I'd like to preserve the coloring.


Solution 1:

Try:

git diff --color > foo.txt

Then later issue:

cat foo.txt

Or:

less -R foo.txt

Solution 2:

Save the file with a .diff extension and open it in Notepad++ or Vim or SublimeText.

git diff > 20150203_someChanges.diff

Thanks @Monsingor

Solution 3:

Open the output diff file in Sublime Text 2. It shows the diff colors.