Sometimes you need additional control over pushes to your repository. GitLab already offers protected branches. But there are cases when you need some specific rules like preventing git tag removal or enforcing a special format for commit messages. GitLab Enterprise Edition offers a user-friendly interface for such cases.

Push Rules are defined per project so you can have different rules applied to different projects depends on your needs. Push Rules settings can be found at Project settings -> Push Rules page.

All you need to do is write simple regular expression that requires mention of JIRA issue in a commit message. It can be something like this /JIRA\-\d+/. Just paste regular expression into commit message textfield(without start and ending slash) and save changes. See the screenshot below:

Now when a user tries to push a commit like Bugfix - their push will be declined. And pushing commit with message like Bugfix according to JIRA-123 will be accepted.

You can turn on a predefined blacklist of files which won't be allowed to be pushed to a repository.

By selecting the checkbox Prevent committing secrets to Git, GitLab prevents pushes to the repository when a file matches a regular expression as read from lib/gitlab/checks/files_blacklist.yml (make sure you are at the right branch as your GitLab version when viewing this file).

Below is the list of what will be rejected by these regular expressions :