How pretty are your Git diff’s?

Git is a very powerful version control tool, one that I’ve talked about a lot before.

One of the great features is the “diff”, which outputs the differences between the code changes that you’ve made and the code that’s committed.  Out of the box, you get something like this…

This is pretty helpful, it tells you lines added (green with a plus) and removed (red with a minus).  For lines that have changed, it outputs as removed (red) and added (green), so you can compare the two lines yourself to see the differences.

It is colour coded, but not what you’d call pretty, sitting in the command line like it does (although the font is beautiful).  And when you’ve made a number of changes, you have to scroll through all the way to the bottom a line at a time, which isn’t very convenient.  (And I always forget that you exit at the end with “q”).

What you need is pretty-diff.  Install it globally like this…

npm install -g pretty-diff

Now you can simply call git pretty-diff instead of git diff and instead of seeing output in the command line, it will be generated as an HTML file and opened in your default browser automatically.  And it looks something like this…

At the end of the day, it comes down to personal preference, but for me, this is definitely a prettier diff, and much easier to use.