Problems with diff between branches on presence of cherry-pick when create pull request

I had a problem when i compare branches on bitbucket.

The issue is: i have a branch called branch_A for example, and start another branch from branch_A  and called branch_B.

Start working on both branches and, one commit for example that originally pushed to branch branch_B, i cherry pick it to branch branch_A .

Then when i try to compare the branches (Creating a Pull Request (PR) between them), i notice that the changes that where made for the commit that was later cherry-picked to branch_A appears to NOT be done. But if i look to the source code, i see that in both branches the changes are already there. 

I wonder why is happens this? If i compare those branches (git diff branch_A  branch_B), is showing all as expected, i use also git diff branch_A branch_B | grep "particular change" and it shows no changes. 

The expected view on Bitbucket tool is that the change must not be shown, because changes are on both branches, yes is true that where pushed with different commit hash, but the lines of code are exactly the same.

Any thoughts?


Thanks and regards


1 answer

1 accepted

1 vote
Jeff Thomas Atlassian Team Sep 30, 2016

This is working as designed. When creating a pull request, Bitbucket Server displays the diff to the common ancestor of the two branches selected. On the command line this looks like git diff -M -C target-branch...source-branch – path/to/file.txt. What this diff shows you is the accumulation of the changes in the source branch since it branched from the target branch.

When you actually create the pull request the diff displayed is the diff which would be applied to the target branch as a result of merging the source branch into it. Locally this would be what you would see if you checked out the target branch and performed git merge source-branch --no-commit.

Most of the time, this diff will be exactly the same, but in some circumstances the diffs can be slightly different. In this instance, since you cherry-picked a change from one branch to the other, the pull request create screen will show that there are changes in a file, even though, the files match on both branches.

The preview may be slightly off, but after creating the pull request we will show the correct result in the pull request diff.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

22,630 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you