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:

The examples on this page use the commitpractice repository.  You can fork commitpractice to your own account to practice on.

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 system lists any branches not already merged into the mainline:

    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 master 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 the public commitpractice repository.
  2. Click + in the global sidebar and select Compare tags or branches under Get to work.
  3. Look for the marysfeature branch.
  4. Press the Compare button on this branch. Change the comparison fields if you like. Bitbucket displays the following: 

    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 master that are not on the 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. Using your commitpractice fork, go ahead and try syncing:

  1. From the sidebar, click Branches.
  2. Locate the meritOrder-feature branch.
  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.
    Bitbucket displays some commands that you can use to merge and sync the branch locally:

    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.
    In this case, I cloned the fork to my local machine and ran the following commands:

    Command 説明
    hg checkout meritOrder-feature
    Checkout the branch.
    hg branch
    Verify I am on the meritOrder-feature branch.
    hg update meritOrder-feature
    As recommend by the Merge changes dialog.
    hg merge 6f2745a5694a 
    As recommend by the Merge changes dialog. Launches my local merge tool, Kdiff, to do the merge.
    hg commit -m "syncing to master"
    Commit the changes.
    hg push 
    Push to Bitbucket.
  8. Press Close.
  9. Push the merged meritOrder-feature back to Bitbucket.
    When you view the new feature branch,you'll find it is no longer "behind" the tip.
     

Close a branch

When you close 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 sidebar, click Branches.
  2. Locate the meritOrder-feature branch.
  3. Click the More button in the top right.
  4. Choose Close branch.
    Bitbucket displays a confirmation dialog. 
  5. Press Confirm.
    Bitbucket close the branch; it no longer appears in your remote repository.
最終更新日: 2017 年 9 月 20 日

この翻訳に満足しましたか?

はい
いいえ
この記事についてのフィードバックを送信する

お探しの情報が見つかりませんか?

コミュニティへの質問

Powered by Confluence and Scroll Viewport.