Enforces a linear workflow policy. This means that any unnecessary merge commits will be rejected. This forces your users to use rebase rather than merge to keep a linear history. This does not affect pull requests, so branches can still be merged, however, the trivial merge commits will be avoided. You can set up your own custom message to appear as the push is rejected.

The hook will list the commit ids that were rejected so that the user knows the commits that are causing the push to be blocked.


> git push
Counting objects: 12, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (12/12), 1.06 KiB | 0 bytes/s, done.
Total 12 (delta 6), reused 0 (delta 0)
remote:
remote: =====================================================================
remote: Rejecting push due to one or more merge commits:
remote: 6378ee0e4e4
remote: ef2dc27692b
remote: Merge commits are not allowed. You should rebase rather than merge.
remote: =====================================================================
remote:
To /bitbucket/scm/project_1/repetition.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '/bitbucket/scm/project_1/repetition.git

This will NOT affect any existing merges, if a merge is already committed and pushed, the hook will not look at that commit, only at new ones.