Manage unmerged branches

Bitbucket Cloud tracks unmerged branches in the Feature branches view. You can use this view to manage your development process by doing any of the following:

List feature branches

A user must push a branch to the Bitbucket remote repository for it to appear as a feature branch. Feature branches lists only unmerged branches. To list the feature branches, log into Bitbucket do the following:

  1. Navigate to your repository.

  2. Select the Commits context from the navigation bar.

  3. Click Show all.

    The displays includes information about the branch in tags next to the date. In the preceding figure you can see the new-feature branch listed. You can also see that there was another branch fix-issue-1 which was recently merged into the main branch making the new-feature branch one commit behind.

Compare a feature branch to the main line

You can use the Compare function to see differences between code lines. This function allows you to see individual files and the changes within those files.  Try a comparison now:

  1. Navigate to a repository with multiple branches. You can always create a branch in an existing repository so you can get more familiar with comparing branches .

  2. Select the More options () button in the upper-right corner of the repository.

  3. Select Compare tags or branches from the dropdown menu.

  4. Select the branch you want to compare to the main branch.

  5. Press the Compare button on this branch. Change the comparison fields if you like.  

    By default, Bitbucket compares the branch to the tip of the mainline. It shows you the changes on the branch that are not on the source. To see the changes on the main branch that are not on the feature branch, you can swap the branches by clicking change destination and change source.

Sync a branch to the mainline

If a feature branch is behind the current branch, you can sync (merge) the branch with the mainline. You sync a branch, for example, to catch your branch up to all the latest changes on the mainline.

  1. From the left sidebar, click Branches.

  2. Locate the branch you created.

  3. From the Commits tab, click Sync now.
    Bitbucket tries to automatically merge for you but only performs primitive merges. Where it detects any conflicts, it asks you to manually resolve these conflicts locally. Bitbucket tells you that there are conflicts.  

  4. Click Close from the Sync branch dialog.

  5. To view the conflicts, click the Diff tab.

  6. Click the Merge button.
    These are the minimum commands you would need to run on your local machine; you may need to do more to merge your files.   

  7. Merge the files on your local machine.

  8. Press Close.

  9. Push the merged branch back to Bitbucket. When you view the new feature branch, you'll find it is no longer "behind" the tip.

Close or delete a branch

When you close or delete a branch, you lose all the unmerged changes on that branch. The branch also no longer appears under the Source list of Branches. You would close an unmerged branch, if for example, the branch represented some experimental testing that failed for which you no longer needed the work.  To close a branch:

  1. From the left sidebar, click Branches.

  2. Locate the branch you created.

  3. Click the More button in the top right.

  4. Choose Delete branch.
    Bitbucket displays a confirmation dialog. 

  5. Press Confirm.
    Bitbucket closes the branch, and it no longer appears in your remote repository.

Additional Help