Day 54: Branching and Merging in Git and Bitbucket

Understanding branching in Git and how it works in Bitbucket

Branching in Git is the process of creating a separate branch of code that allows you to work on new features or bug fixes without affecting the main codebase. This is particularly useful when working with teams, as it enables multiple developers to work on different parts of the same codebase simultaneously.

In Bitbucket, branching works in a similar way to Git. Here are the steps to create a new branch in Bitbucket:

  1. Navigate to the repository you want to create a new branch for.
  2. Click on the “Branches” button located at the top of the page.
  3. In the following screen, click on “Create branch”.
  4. Name your new branch and select whether you want it to be based on an existing branch or commit.
  5. Optionally, add a description for your new branch.
  6. Finally, click on “Create”.

You’ve now created a new branch in your Bitbucket repository! You can now make changes and commits to this branch without affecting the main codebase.

Once you’re done making changes in your branch, you can merge it back into the main codebase using a pull request. This allows other team members to review and approve your changes before they’re merged into the main codebase.

To create a pull request in Bitbucket:

  1. Navigate to your repository’s homepage and click on “Create pull request”.
  2. Select your source and destination branches (the one you want to merge into).
  3. Add a title and description for your pull request.
  4. Review any conflicts that may arise during merging and resolve them if necessary.
  5. Once everything looks good, click “Merge” to merge your changes into the destination branch!

That’s it! You’ve successfully used branching and merging in Bitbucket.