Sebastian De Deyne
Designer & developer at Spatie

Things you didn't know you could diff in GitHub

If GitHub is your daily driver or you’ve contributed to open source at some point, you’ve probably seen the comparison screen before.

Screenshot of GitHub’s compare screen

“Compare and review just about anything”

They’re not lying. You can compare a lot in there, but most of it isn’t available in the UI. Here are a few tricks you probably didn’t know about.

Comparing with a previous commit

https://github.com/spatie/laravel-medialibrary/compare/<hash>...master

Live example

If you compare the current version of master with a previous commit, use the commit hash separated by three dots.

Comparing commits

https://github.com/spatie/laravel-medialibrary/compare/<hash>..<hash>

Live example

If you want to compare two arbitrary commits, use the commit hashes separated by two dots.

Time-based comparison

https://github.com/spatie/laravel-medialibrary/compare/master@{<date>}...master

Live example

You can also compare a branch to a specific point in time. The date can either be absolute (master@{2020-08-01}...master) or relative (master@{10day}...master).

If you enjoyed this post, you might be interested in my newsletter. I occasionally send a dispatch with personal stories, things I’ve been working on in the past month, and other interesting tidbits I come across online.