Solution 1:

wget "http://www.pixelbeat.org/scripts/ansi2html.sh" -O /tmp/ansi2html.sh
chmod +x /tmp/ansi2html.sh
git diff --color-words --no-index orig.txt edited.txt | \
/tmp/ansi2html.sh > 2beshared.html

What I really needed was an ANSI to HTML converter. And I found a very decent one on http://www.pixelbeat.org/.

NOTE: You might not see any coloration unless you include --color or --color-words, probably because piping causes git diff to exclude colors.

NOTE 2: You may need to install gnu sed and awk, especially if you're on a Mac. Do so with brew install gnu-sed gawk. You may need to add them to your path manually, too, e.g. with ln -s /usr/local/Cellar/gnu-sed/4.2.2/bin/gsed /usr/local/bin/.

Solution 2:

download diff2html, extract it and convert diff to html with this command:

$ diff2html file1.txt file2.txt > diff-demo1.htm

There is more ... take a look at this question.

Or after gitting:

git diff --color-words --no-index orig.txt /tmp/edited.txt > myfile

download both ansifilter from this location. and use this command to convert myfile to html format

ansifilter -i myfile -H -o myfile2.html

so ... this is exactly what you want ;)