Commit 60471a75 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'patch-1' into 'master'

fix typos & add links in Push Rules docu [skip ci]

See merge request !757
parents 2a5ef580 8cb59853
# Push Rules
Sometimes you need additional control over pushes to your repository.
GitLab already offers protected branches.
GitLab already offers [protected branches][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 are defined per project so you can have different rules applied to different projects depending on your needs.
Push Rules settings can be found at Project settings -> Push Rules page.
## How to use
Let's assume you have the following requirements for your workflow:
* every commit should reference a reference JIRA issue. For example: `Refactored css. Fixes JIRA-123. `
* every commit should reference a JIRA issue. For example: `Refactored css. Fixes JIRA-123.`
* users should not be able to remove git tags with `git push`
All you need to do is write simple regular expression that requires mention of JIRA issue in a commit message.
All you need to do is write simple regular expression that requires mention of a 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.
Just paste regular expression into the commit message textfield (without start and ending slash) and save changes.
See the screenshot below:
![screenshot](push_rules.png)
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.
Only pushing commits with messages like `Bugfix according to JIRA-123` will be accepted.
## Prevent pushing secrets to the repository
......@@ -91,3 +91,5 @@ pry.history
bash_history
```
[protected-branches]: https://docs.gitlab.com/ee/user/project/protected_branches.html "Protected Branches documentation"
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment