Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare two commits in BitBucket?

Tags:

git

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.

like image 491
ng10 Avatar asked Jun 30 '18 15:06

ng10


People also ask

How do you compare different commits?

You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch. Order does matter when you're comparing branches.

How do I compare two commit codes in git?

You can also compare two arbitrary commits in your repository or its forks on GitHub in a two-dot diff comparison. To quickly compare two commits or Git Object IDs (OIDs) directly with each other in a two-dot diff comparison on GitHub, edit the URL of your repository's "Comparing changes" page.


2 Answers

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'
like image 158
Alastair Wilkes Avatar answered Sep 20 '22 22:09

Alastair Wilkes


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

like image 28
kambala Avatar answered Sep 20 '22 22:09

kambala