How to compare two commits in BitBucket?

I was trying to compare two commits on the same branch (master in this case) in BitBucket and did not find a good answer in any forum, so decided to try their client, SourceTree to see if installing it locally would help and it did.

Therefore, thought it might be useful to add question and answer here.


Solution 1:

BitBucket Cloud (bitbucket.org) supports commit comparison on the branch compare page:

  1. Navigate to a repo
  2. Click the '+' menu in the left-nav
  3. Click 'Compare branches and tags'
  4. Paste your commit hashes into the search fields in the branch/tag dropdowns
  5. Click 'Compare'

Solution 2:

This URL worked for me: https://bitbucket.org/<OWNER>/<PROJECT>/branches/compare/<commit1>..<commit2>#diff, short hashes can also be used.

Screenshot:

enter image description here

Solution 3:

I came across this question while looking for a way to compare a single file across two different commits. The instructions for doing so are slightly different than those above, so I wanted to share:

  1. Browse to the file in question in the "Source" view
  2. Drop down the file's view option and select "Diff":

'Diff' view option

  1. Once the file's diff has loaded, drop down the history options and select the commits that you want to compare between:

Select commits to compare