How to create a Pull Request Preview comparing commits (not branches)
A challenge we have often is - when giving updates - being able to effectively show what code was changed in the codebase since our last check in.
The default way to do this is via a standard Github Pull Request. This should always be the first option.
Sometimes though, we are committing to the same branch and want to just show the changes that happened between our commit and the previous commits.
To let us do this, Github has a hidden way to let us compare commits in it's web based diff viewer.
Steps
Push your changes to the branch (usually
dev
) as normalGo to the Commits section in Github

Grab the hash of your most recent commit, and also the hash of the commit before you made any changes.

Construct a url that follows the below format (notice the
...
between the two commits)
https://github.com/{username}/{repository}/compare/{commit_hash}...{commit_hash}
Example
Let's use an example from our open source H1 Rails codebase
First commit hash: eda93a0bde19f5fc72b94715d7a036284b8a1e60
Second commit hash: e7e46ff4a67d73d3ce8c03d2428861b6b71888cc
Last updated