Skip to content
GitLab
Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    Projects Groups Snippets
  • Sign up now
  • Login
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 46,666
    • Issues 46,666
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,519
    • Merge requests 1,519
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #150
Closed
Open
Issue created Dec 28, 2015 by Job van der Voort@JobV🚀Contributor

Auto-squash commits when merging merge request

Resources

PM @victorwu | BE @smcgivern | UX @pedroms | FE @mikegreiling


Problem

Similar to #895 and explained in #411 (closed), we would like to reduce the friction in getting code merged into a master / main development branch for typical development scenarios.


Solution

  • For all merge request methods (merge commit, merge commit with semi-linear history, fast-forward merge), allow the user to squash all the commits and merge in one action.
  • Squash is a checkbox, like the remove source branch checkbox, that is available on MR creation/edition, or when the accept button is visible, and it can be changed by anyone who can accept the MR or the MR author.
    • This checkbox is always shown on create and edit.
    • This checkbox is only shown when accepting if there is more than one commit in the MR - otherwise, there's nothing to squash.
  • We will never update the source branch with the squash result, just the target branch.
  • For the different merge methods:
    • Merge commit - we squash the commits in the MR based on the base SHA (the common ancestor between source and target), then merge that commit into the target branch as normal.
    • Merge commit with semi-linear history - we do the same, but the rebase start point is the start SHA (the current target branch HEAD).
    • Fast-forward merge - we also rebase to the start SHA, but then we just fast-forward that commit onto the target branch.
  • We should always squash before rebasing, because then we know that the resultant squashed commit can be either merged or rebased cleanly based on our existing checks.
  • This applies to automatic merges as well. When a user sets a merge to be automatically attempted after the pipeline succeeds, it is as if they execute this one action of rebase+merge.

Designs

New/edit MR View MR (desktop) View MR (tablet) View MR (mobile)
new-edit image image image

In the New/edit MR screen, the “Learn more” links to the documentation.

In the View MR screen, the ❔ question icon should have a “Learn more” tooltip and link to the documentation. It's default color is $gl-gray-light and on hover changes to the link hover color. The "Learn more" should be "About this feature", as per https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1024#note_21099369


Original issue

https://gitlab.com/gitlab-org/gitlab-ce/issues/4106

Provide a "Squash into one commit upon merge" checkbox.

See @dzaporozhets comment for details: https://gitlab.com/gitlab-org/gitlab-ce/issues/4106#note_3036031

cc @sytses

Working issue: #896 (closed)

Edited May 19, 2022 by Coung Ngo
Assignee
Assign to
Time tracking