Wei Zhang's Blog

06 Feb 2022

Diff2html: Displaying changes between two versions of a git repository

diff2html is a package which can be used to display differences between two commits of a git repository in HTML format. Suppose that we are in a git repository. By running the command

git log --pretty=format:"%h %s"

we get the output

7cbfbc7 Set gradient to zero when the grad tensor is undefined
530419f Updated README
0635cab Updated README
bc18a96 Add usage and example in README

To see the changes we made in the commit with hash 530419f based on the commit with hash 0635cab, we can use the following command.

diff2html -s line -f html -d word -i command -o preview -- -M 0635cab..530419f

The output HTML file will be opened in the internet explorer, which shows the changes between these two commits.

See the github page of diff2html-cli for more information on its usage.

Tags

git