Create and push a branch

Branching offers a way to work on a new feature without affecting the main codebase. After you make changes, push your branch to Bitbucket Cloud so that you can get it reviewed in a pull request.

Create a Git branch

If you want to create a Git branch, the best way to do it is from Bitbucket.

  1. Click Create branch in the left panel.
  2. From the popup that appears, enter a Branch name and click Create.
  3. After you create a branch, you need to check it out from your local system. Use the fetch and checkout commands that Bitbucket provides, similar to the following:

    $ git fetch && git checkout <feature>
  4. Make your changes locally and then add, commit, and push your changes to the feature branch:

    $ git add .
    $ git commit -m "adding a change from the feature branch"
    $ git push origin <feature>
  5. View the Source page of your repository in Bitbucket. You should see both the master and the feature branch. When you select the feature branch, you see the Source view from that perspective. Select the feature branch to view its Recent commits.

Create a Mercurial branch

If you want to create a Mercurial branch, the best way to do it is locally.

  1. Create a new feature branch in the repository.

    $ hg branch <feature_branch>

    Nothing changes in the working directory. The branch command tells Mercurial the branch name to use with your next commit. If you use the hg branches command, you'll see you still only have the default branch.

  2. Edit files, add files, and commit in the working copy.

    $ hg add
    $ hg commit -m "adding a change from the feature branch"
  3. Push the feature branch to Bitbucket.

    $ hg push --<feature_branch>

Last modified on Feb 22, 2017

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.