JetBrains Space EAP Help

Merge Requests

Before merging a branch you've been working on into the base branch (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

  1. Follow the graph on the commits list to locate the branch you want to merge.

  2. Select the top commit of the branch.

  3. On the right pane, click Review changes and choose Create merge request:

    mergeRequest.png

    A diff will be displayed. It shows the differences between the latest revision of the selected branch and the head of the default branch (e.g. master).

  4. Press Create merge request on top of the page:

    createMergeRequest.png

    A merge request code review will be created:

    mergeRequestReviewCreated.png
  5. Assign reviewers as with a regular code review and wait for the reviewer's approval or feedback.

  6. Now you can:

    • Compare your branch with the branch you want to merge to.

    • Check your status.

    • Reply to reviewer's feedback or proceed to merge when your request is approved.

Review a merge request

If someone wants you to review 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.

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 (the default branch e.g. master). For this diff view, all commits should be selected in the left pane:

mergeRequestDefaultDiff.png

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:

  1. Follow the graph on the commits list to locate the branch that should be merged, or go to Branches and open the branch.

  2. Select the top commit of the branch.

  3. On the right pane, click Compare to default:

    clickCompareToDefault.png

    A diff will be displayed. It shows the differences between the head of the selected branch and the head of the default branch.

  4. Review the changes and check for conflicts.

Check your status

In a code review, participants take turns to keep the process clear and orderly. A status indicator at the top-right will tell you whether you should wait or take action.

authorStatusWaiting.png

Blue color indicates that no action is required, wait for the reviewer to finish their turn.

authorStatusRevising.png

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 on the status indicator to change your status and pass the turn to the reviewer.

authorStatusEnd.png

Indicates that the review is complete and your branch can be merged. Click the arrow on the status indicator to proceed.

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):

mergeRequestApproved.png

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 on 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 on 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 you feature branch to the default branch with a merge commit.

  1. Open the review page and click Merge:

  2. Choose Merge.

    mergeOptionsMerge.png
  3. If you want your branch deleted after the merge, select the corresponding checkbox.

  4. Click Merge.

    Your branch will be merged into the default branch and the history of all commits will stay intact.

    mergeBeforeAfter.png

After you've merged the branch, you can close the review.

Rebase and merge a branch

This option lets you rebase you feature branch before it is merged into the defalt branch. All commits of your feature branch will be added on the tip of the default branch without a merge commit.

You can also choose to delete your branch after the merge.

  1. Open the review page and click Merge:

  2. Choose Rebase:

    mergeOptionsRebase.png
  3. If you want your branch deleted after the merge, select the corresponding checkbox.

  4. 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.

    rebaseBeforeAfter.png

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 defalt branch. All commits of your feature branch will be combined into one and then added on the tip of the default branch without a merge commit.

You can also choose to delete your branch after the merge.

  1. Open the review page and click Merge:

  2. Choose Rebase and squash:

    mergeOptionsSquashRebase.png
  3. Enter your commit message for the squashed commit.

  4. If you want your branch deleted after the merge, select the corresponding checkbox.

  5. 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.

    squashBeforeAfter.png

After you've merged the branch, you can close the review.

Last modified: 17 June 2020