Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I tell which commits a branch is ahead by?

Mik Clarke October 30, 2019

On the BitBucket Branches display, it comes up with behind/ahead values for branches other than my main one.  Fair enough. Behind are commits in main that aren't in the branch, ahead is commits in the branch that aren't in main.

How do I get a list of the commits, in a specific branch, that are 'ahead' (not included) in the main branch?  I'm assuming most of the ahead commits will be stuff that got cherry-picked, manually re-coded or abandoned.  What I want to find are legit changes that didn't make it into the main branch (because these now need to be reviewed and cherry picked).

Mik

1 answer

1 accepted

2 votes
Answer accepted
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 30, 2019

Hello @Mik Clarke,

Thanks for reaching out.

So both "ahead" and "behind" refer to the diff between the tip of one branch and the merge base of that branch with the other branch – the commit after which the branches diverged. Depending on tip of which branch you use, it becomes "ahead" (tip of "this" branch compared to the merge base) or "behind" (tip of "the other" branch compared to the merge base).

This was a longer version of what you described basically, but it explains the following: branch diff view shows this kind of diff between branches, so it can show "ahead" or "behind", depending on the order of branches you select there.

On the branch list view click on the branch you want to compare to some other branch – this will get you to the branch diff view. Then select that other branch in the destination dropdown (by default it'll be the main branch of your repository). The result will be "branch ahead of main (or some other branch you selected)". If you swap the branches, it'll be "branch behind main (or some other branch you selected)".

Here's the direct URL format for that view:

https://bitbucket.org/<account>/<repository>/branch/<branch_name>?dest=<URL_encoded_destination_branch_name>

Hope this helps. Let me know if you have any questions.

Cheers,
Daniil

Mik Clarke November 3, 2019

Ah, ok.  The big 'this branch is 60+ commits behind the main branch' banner made me think that page listed all of the 'missing' commits, but looking at it again I can see it's only showing the ahead ones. 

Any chance of linking to it from clicking on the 'ahead' or 'behind' values shown on the branches page?  At present clicking on them does nothing, which made me think the feature wasn't supported.

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 3, 2019

Yeah this sounds totally legit, I'll chat with the team about this use case. Actually, if you create a feature request ticket, it'd be great. This way you'll get notified when we do something about it, and also other people might vote for it.

Cheers,
Daniil

Like Daniil Penkin likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events