How to make CodeOwners review mandatory before merging PR?

We started using the code-owners feature in our repository. It is cool and good so far. 

I want to make a code-owners review and approval mandatory on PR before it gets merged. Right now. I don’t know how to make it mandatory. Please help me to understand and implement it on how to make it mandatory.

Thank you.

Please help.

Hi @yogesh-desai,

Thanks for being here! Once you configure your protected branches, repository administrators can enforce required reviews so that pull requests required review from a code owner when the pull request affects code that has a designated owner. For more information, see “About code owners.”  I hope this helps!

1 Like

Hi @AndreaGriffiths11,
Thank you for your reply. I have already followed these steps. Right now, in the repository, there are many people who have access to merge the PR (all these are code-owners). What I am interested in is, One code-owner can only merge PRs for which he/she owns the code. One code-owner can not merge PRs if he/she does not own that particular code.

Is it possible? Please help.

I’m not sure if that is possible, but you can restrict who can merge PRs overall.

1 Like

Thanks for the follow-up @yogesh-desai@rdil is correct you can use branch restrictions for this. When you enable branch restrictions, only people or teams that have been given permission can push to the protected branch. You can view and edit the users or teams with push access to a protected branch in the protected branch’s settings. I hope this helps!

1 Like