Merge Requests
Before merging a branch you've been working on into the base branch (main, master), you can create a merge request inviting your teammates to examine and approve the changes.
Merge request is a special kind of code review that lets you:
Compare the two branches.
Easily spot conflicts if any.
Merge your branch right from the review page (rebase and squash as well).
Create a merge request
Follow the graph on the commits list to locate the branch you want to merge.
Select the top commit of the branch.
On the right pane, click New merge request:
A dialog with merge request options will pop up.
Select the target branch (the branch you want to merge into):
Add description (optional):
Click Add description.
Type you description into the text field or click Copy text from commit messages.
Description based on commit messages can be edited using Markdown.
You can also edit the title of this merge request.
Assign reviewers:
If your merge request requires approval from certain people as part of Quality gates protection, Space will suggest them for reviewers. Please add these suggested reviewers and get their approval, otherwise you won't be able to merge your changes:
Click Create merge request.
A merge request code review will be created:
If your merge request includes changes in files owned by an assigned reviewer, you can indicate whether you want that reviewer to examine all changed files or only the ones they own:
Your selection determines what the reviewer will initially see in the Changes tab: either all changed files or only the ones where they are the code owner.
Code ownership is based on the
CODEOWNERS
file which can be configured for your repository.Now you can:
Review a merge request
If someone asks you to review and approve their merge request, follow the instructions outlined in Review Changes Made by Others.
In addition, you may need to:
Compare the branches before approving the request.
Choose whether you want to review all files included in the merge request or only those you own.
Code ownership is based on the
CODEOWNERS
file which can be configured for your repository.All files — With this option selected, if you Approve changes, your approval will be reset when additional changes are introduced to any files.
If you Approve and finalize, your status will stay final, it won't be reset with new commits.
Owned files — With this option selected, if you Approve changes, your approval will be reset only if changes added afterwords affect the files you own. Changes made to any files you don't own will not reset your status.
If you Approve and finalize, your status will stay final irrelevant of the files affected afterwords.
Compare branches and commits
The default diff view of the Merge request code review shows the difference between the head of the source branch (the branch being reviewed) and the head of the target branch. For this diff view, all commits should be selected in the left pane:
If the system detects any conflicts that cannot be resolved automatically, a warning will be shown:
Files with conflicts will be labeled with a red exclamation mark. A conflicting branch cannot be merged until all conflicts are manually fixed.
You can also compare the source branch commits with their parent commit. To do so, in the left panel, select only the commit you want to compare.
The branches can be also compared from the commit list:
Follow the graph on the commits list to locate the branch that should be merged, or go to Branches and open the branch.
Select the top commit of the branch.
On the right pane, click Compare to default:
A diff will be displayed. It shows the differences between the head of the selected branch and the head of the default branch.
Review the changes and check for conflicts.
Code analysis
If your project is integrated with an external code analysis tool, all changes within a merge request will be inspected, a summary will be displayed on the merge request page and code problems will be highlighted in the merge request diff.
The code analysis summary is shown in the right-hand Details panel:
Erroneous code fragments are underlined with a red squiggly line in the merge request diff. Click on the line to see the error description:
Check your status
In a code review, including merge requests, participants take turns to keep the process clear and orderly. The status indicator under your name in the right-hand panel will tell you whether you should wait or take action.
Gray color indicates that no action is required, wait for the reviewer to finish their turn. | |
Orange color indicates that it's your turn, and you are expected to take some action such as:
Once you're finished, click the suggested action in the top right corner to change your status and pass the turn to the reviewer. | |
A blank status under your name indicates that the review is complete and your branch can be merged. Click the Merge button to merge your branch and close the review. |
Reviewer's approval
When reviewers accept your changes, you are notified in Chats. Their resolution will be also posted on the review page under the Timeline tab, and indicated on their user icons (they will be encircled in green):
Merging options
As soon as the reviewers accept your request, you can merge your branch into the default branch right from the Space interface.
You have the following options:
Merge — merge your branch back into the default branch with a merge commit.
Rebase — move your branch to the tip of the default branch without a merge commit.
Rebase and squash — combine all commits from your branch into a single commit and move it to the tip of the default branch.
You can also choose whether to keep your branch after the merge or delete it.
Merge a branch
This option lets you add all commits from your feature branch to the default branch with a merge commit.
Open the review page and click Merge:
Choose Merge.
If you want your branch deleted after the merge, select the corresponding checkbox.
Click Merge.
Your branch will be merged into the default branch and the history of all commits will stay intact.
After you've merged the branch, you can close the review.
Rebase and merge a branch
This option lets you rebase your feature branch before it is merged into the default branch. All commits of your feature branch will be added to the tip of the default branch without a merge commit.
You can also choose to delete your branch after the merge.
Open the review page and click Merge:
Choose Rebase:
If you want your branch deleted after the merge, select the corresponding checkbox.
Click Merge.
Your branch will be rebased and merged into the default branch without a merge commit. The commit history will be rewritten resulting in a linear commit graph.
After you've merged the branch, you can close the review.
Squash, rebase, and merge a branch
This option lets you squash your feature branch into a single commit and then rebase it before it is merged into the default branch. All commits of your feature branch will be combined into one and then added to the tip of the default branch without a merge commit.
You can also choose to delete your branch after the merge.
Open the review page and click Merge:
Choose Rebase and squash:
Enter your commit message for the squashed commit.
If you want your branch deleted after the merge, select the corresponding checkbox.
Click Merge.
Your branch will be squashed into a single commit, rebased and merged into the default branch without applying a merge commit. The commit history will be rewritten resulting in a linear commit graph and fewer commits.
After you've merged the branch, you can close the review.