behind/ahead incorrect

This question is in reference to Atlassian Documentation: Using branches in Bitbucket Server

What I wanted to do:

  delete merged branches by using 'master' branch as comparison using the Behind/Ahead function.

Problem:

  I found many of the branch contain just 1 or 2 commit Ahead of the master branch. So i try to see the diff with 'create pull request' function. I confirmed that Bitbucket show me there are diff between the two branch. I proceed by clicking the 'create' button.

  then the system show me that there are no changes on the diff tab.

Question:

  Is that Bitbucket having some problem when comparing branches and show me the wrong 'Behind/Ahead' status??

bitbucket behind ahead branch incorrect.png

1 answer

1 accepted

0 vote
Jeff Thomas Atlassian Team Aug 04, 2016

Hi,

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.

This is what appears to be happening from the screenshot you provided. The preview for the pull request shows that there are changes to be applied (likely the 1 commit that's ahead), but when we're actually displaying the pull request diff, there are no changes to be applied from the source branch to the target branch. Is is possible that changes were cherry picked from the source to destination branch? 

Also, if you manually run the git diff and git merge commands from above, do you get the same results as what Bitbucket Server is displaying?

Hi, 

Thank for the quick reply.

As you had guess, out work flow didn't merge the develop branch directly into master. I guess that is the reason why BitBucket show me the behind/ahead like that.

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...

31,605 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