AI & Software · Tutorial
How to Compare Two Commits on GitHub
See which files and lines changed between two GitHub commits, and understand what the comparison can and cannot tell you.
Disclosure: We may earn a commission when you shop through the links below. It never changes the verdict. Details

Disclosure
We may earn a commission when you shop through the links below. Opinions stay independent. Full disclosure
An update broke something, or an AI coding agent says it changed “a few files.” Before you accept that description, look at the actual changes. GitHub’s comparison view can show the differences between two known commits right in your browser.
Quick answer: In the repository’s URL, add /compare/OLDER..NEWER, replacing those placeholders with the two commit IDs. GitHub labels the first as the base and the second as the comparison. Review the changed files, additions and deletions before drawing conclusions.
We opened GitHub’s public Linguist example and inspected its direct comparison. We did not review a private repository or create a pull request.
1. Find the two revisions
Start with the correct repository and identify the older and newer commits you want to compare. GitHub’s comparison guide explains that you can use commit IDs in the comparison URL. Check the repository’s commit history if you need to find them; a single file’s history can differ from the repository-wide history.
For an agent-generated change, ask for the starting and ending commit IDs and confirm that both belong to the project you intend to inspect. A branch name can move as new commits arrive; a commit ID points to a specific revision. Keep any private repository links within the people authorized to see them.
2. Open the direct comparison
- Open the repository on GitHub and add
/compareto the repository URL. - For a direct comparison of two commits, use the pattern
/compare/OLDER..NEWER. Replace the placeholders with your own commit IDs, older first. - Check the base and compare labels. If the results don’t look right, verify the repository and both IDs before interpreting the diff.
For a safe example, GitHub’s documentation uses f75c570..3391dcc in Linguist. When we opened it, GitHub displayed two changed files, nine additions and three deletions. That example describes those particular revisions, not a typical result.

3. Read what changed
The file headers tell you which files differ; the summary counts added and deleted lines. In the diff, lines marked - are removed from the base version and lines marked + are added in the comparison version. Read surrounding context too: a small line count doesn’t prove a change is safe or harmless.
Check whether the files and changes match the task, whether tests or configuration changed, and whether anything unexpected appears. A comparison shows differences between revisions; it doesn’t prove the software works, that tests passed, or that a change is secure.
The two-dot URL above is the direct comparison shown in our example. GitHub also offers a default comparison using three dots, which can differ when histories diverge. Don’t silently swap the two when you need exact endpoints; GitHub explains the distinction in its comparison documentation.
If GitHub can’t find a revision, double-check the repository, spelling and access. If the page is empty, confirm the chosen revisions and comparison direction. Never paste private code or sensitive repository links into an unrelated service to troubleshoot.
Need the installable app instead of the code diff? Our GitHub Releases guide covers finding the right download.
How we checked: We opened GitHub’s documented public comparison and inspected its base, compare, summary and diff. We did not test branch selection, private repositories, or pull-request creation. GitHub’s documentation supports the URL and comparison details.
The Inner Circle
One AI shortcut a week. Tested first.
The tools and tricks I actually kept using, sent once a week. Skip the hype threads.
- New verdicts and scores
- Same-day workflow tips
- No spam, unsubscribe anytime



