Create a pull request
When you use branches or forked repositories to work on a separate line of code from the codebase, you can use pull requests to get your code reviewed and merge your changes from Bitbucket Cloud. When you're ready to start a discussion about your code changes, it's time to create a pull request. Before creating a pull request, you might want to compare your code changes to the destination repository.
- Try to make the pull request small enough to review but large enough to give you the context of the feature, bug fix, or update.
- Use @mentions in your comments to guide reviewers or the pull request creator to specific items in the code.
- Create Tasks for things that must be addressed for approval to help designate between suggestions and discussions and things that must be fixed.
- Provide an accurate description and links to any issues to give reviewers more context and better access to what they need to understand the problem or feature you're addressing.
Compare code between the source and destination
When you compare branches or tags, you can select any two branches or tags to see a diff of the two. You might want to compare the updates you made with the destination branch to see all that you changed and how much the destination branch changed while you worked.
To compare your source code changes to the destination, do the following:
- From the repository with your changes, click + in the global sidebar and select Compare branches or tags under Get to work.
Bitbucket displays the Compare page.
- Adjust the source (top) and destination (bottom) fields so they match the pull request you anticipate making.
- Press Compare.
If there are changes, you'll see a Diff and a list of Commits. If the destination repository has new changes, you'll see (#) commits behind staging under the Commits tab with a Sync now link if you want to update your branch with the new commits.
If there are no differences between the branches or tags, Bitbucket reports There are no changes.
Create a pull request
To create a pull request, you need to have made your code changes on a separate branch or forked repository.
- From the open repository, click + in the global sidebar and select Create a pull request under Get to work.
- Fill out the rest of the pull request form. See the screenshot below for a description of each field.
- Click Create pull request.
After creating a pull request, you can modify its description or anything else on the form by clicking Edit on the pull request's page.
Here's what the pull request form looks like:
- A. Source: The source repository and branch is where you made your code changes that you want to merge. The repository generates automatically based on the repository you're looking at, but you can change the branch so check to be sure you're merging the correct branch.
- B. Destination: The destination repository and branch is where you want to merge the source.
- C. Title and Description: You'll see both in email notifications and the title appears in the pull request list.
- D. Reviewers: Users who you want to review your pull request receive a notification by email. Select reviewers who will give effective feedback and to make key contributors aware of the changes. Enter their Bitbucket username or email address in this field. Reviewer can comment on the pull request and give their approval with a single click. If you make changes to your branch, reviewers will see those changes as soon as the new commit is made.
E. Close branch: Select this option if you want to automatically close the branch when the pull request is merged. The closed branch no longer appears in your branches list in Bitbucket.
A repository admin can use branch permissions to restrict this option in Git repositories. Mercurial repositories will always have this option.
- F. Diff and Commits: Check these tabs to compare new changes and see relevant commits.
- Diff: Shows a comparison of the changes in your pull request to the files in the destination branch.
- Commits: displays a list of all the relevant commits. This list will update with commits you make on the source branch until the pull request is either merged or declined.