You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!


Enforce Squashed Commits


Force all commits present on a branch to be squashed into a single commit before merging.


You want to stop your team merging branches with multiple commits. Use this script to enforce squashing all commits before a branch can be merged.

Good to Know

  • This script only checks commits created after the branch was created.


  • Bitbucket Bitbucket (6.3 - 7.12)
  • ScriptRunner for Bitbucket ScriptRunner for Bitbucket (6.11.0)
import com.atlassian.bitbucket.pull.PullRequestService import com.atlassian.sal.api.component.ComponentLocator def pullRequestService = ComponentLocator.getComponent(PullRequestService) def pullRequest = mergeRequest.pullRequest if (pullRequestService.countCommits(, > 1) { mergeRequest.veto("Commits have not been squashed", "You should squash your commits into one before merging.") }
Discovered an issue? Report it here

Suggested for you