Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,299,230
Community Members
 
Community Events
165
Community Groups

What does the behind/ahead column mean in the branch view

Deleted user Oct 01, 2019

On 1 of the repo I work, one of the feature branch behind/ahead column says 41/36 (aka 36 ahead and 41 behind). The branch has been merged so I would assume the branch should be behind....

So my questions are:

-What does the behind/ahead column mean ?

- How a branch can be both behing and ahead of another branch ?

Thanks for your help

2 answers

The OP said "The branch has been merged" so I would think the branch should no longer be "Ahead" of the master branch. We have the same issue. The branch has already been merged but it says the branch is still multiple commits "Ahead" of the master branch. When I go to Create a Pull Request, it says "There are no changes. No commits on BranchName that aren't on master." and will not let me click on the "Create pull request" button.

same problem here. 

E.g. I merge /develop into /master. After that, my develop branch is 1 behind master (expected) but still many commits ahead. Creating a new PR from /develop to /master shows me all previous changes again in the description although no files are changed.. 

Like # people like this
1 vote
Mikael Sandberg Community Leader Oct 01, 2019

Hi @[deleted],

Welcome to Atlassian Community.

What the the behind/ahead column is telling you that you have made changes on your branch that has not yet made it to the default branch (the branch Bitbucket is comparing against), meaning your branch is ahead. If there are changes on the default branch that has not yet made it into your branch, then it means your branch is behind the default branch. A branch can be both ahead and behind at the same time if you have made changes to your branch, and someone else have made changes on the default branch that you have not merged into your branch yet. 

I have a branch with 6 commits, and it shows 4 commits behind master in Bitbucket Cloud. If I click Sync now, what will happen?

In my local repo, when I run git status, both master and branch are up to date with origin/master and origin/branch, respectively.

Mikael Sandberg Community Leader May 11, 2021

@Aquib Mir this should be its own question, and you could reference this on in it.

Anyways, when you click sync it will only sync your local branch to your remote branch. The 4 commits behind master just means that your branch is out of sync with the master, and you should do a merge from master to your branch in order to get the latest changes from master into your branch. When you do this merge depends, I have always recommended my users that do merges from master/dev to their branches often and early, that way you will avoid having to make major changes on your branch at the end.

Clear as mud!

Like David McBride likes this

Still confused.  After I click sync on a particular branch (let's call it BranchA) from the Branch view, the Commits view shows "Merged master into BranchA".  This implies that the sync function is actually syncing up remote master with the remote BranchA.  But even after this, I see the remote BranchA ahead of master on the Branch view.

Mikael Sandberg Community Leader May 13, 2022

@karunt Syncing a branch is not equal to merge. Only a merge to the default branch will reset the ahead/behind count.

From the Branches view, the Actions for the master branch don't give me a choice to merge with any other branch.  So how can I merge master into BranchA to make sure BranchA isn't ahead or behind master?

Here's a screen shot, showing the options for master branch - no merge option available.

 

Screenshot (67).png

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,238 views 2 9
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you