Updated on 2024-11-22 GMT+08:00

Creating a Squash Merge

Squash merge is to merge all change commit information of a merge request into one to simplify the commit information. When you focus only on the current commit progress rather than the commit information, you can use squash.

If Squash is selected, multiple consecutive change records of the source branch can be merged into one commit record (information of Configure Squash), and this new commit record can be committed to the target branch.

  • If the change history of the merge request contains only one commit, the commit record in the target branch is for the source branch after Squash is selected.
  • If the change history of the merge request contains multiple commits, the commit record in the target branch contains the information of Configure Squash after Squash is selected.

To better understand this function, perform the following operations:

  1. Create a repo and a branch.

    The repo name is repo, and the branch name is Dev.

  2. Dev branch: Create two files and name them Function_1 and Function_2.
  3. Check the effect before Squash is enabled. Click the Dev branch and choose Code > Commits > Commits to view the commit information.

  4. Create and merge a request.

    1. Set the source branch to Dev and target branch to master. Create a merge request.

      Dev branch: Name the merge request as Squash, select Squash, and enter Configure Squash.

    2. After the merge request is reviewed and approved, the request can be merged.

  5. Check the effect after Squash is enabled. After the request is successfully merged as shown in the following figure, click the Code, Commits, and Commits tabs, select the master branch. Compared with Step 4, the committed content has been merged.