Allow specific source branch to merge to target branch

Hello, I’m wondering if Gitlab has a feature where you can restrict a merge request to only have a specific source branch to a specific target branch. Let me explain here.

So the “PROD” branch (final branch) would be called master. The next branch would be called develop and the last branch would be called whatever feature you want. So in this case, I want the workflow to be as follows.

Feature branch (merge request) -> develop
develop (merge request) -> master
master is final branch

So what I’m trying to say here is I only want to allow the develop branch to be able to merge to the master branch. If someone were to say “attempt” to merge a feature branch into the master branch, it’ll reject the merge request. So something like this

Feature branch (merge request) -> (x) master
develop (merge request) -> (✓) master

My question is, is this possible in Gitlab and if so is it available in the free version or does this need to be the enterprise edition?


This feature has been implemented in 16.5 and according to the documentation, it is unfortunately available only for Premium and Ultimate customers.

However, please note that this is not a restriction - it is only a rule for GitLab to autofill the target branch when creating a Merge Request from a specific branch, to simplify the MR workflow. Developer can still manually choose a different branch by him/herself.

Hope this helps :slight_smile:

1 Like

Yes it helped. I guess if there were ever to be a “restriction” feature like I mentioned, it’ll most likely be a premium feature?