Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSTS - prevent push to master but allow PR merge

We have branch policies set up in VSTS to prevent pull requests being merged into master unless a build passes and work items are linked. However, I can't work out how to prevent developers pushing directly to master. Setting the "Contribute" permission to Deny does not allow pull requests to be merged.

All developers should be allowed to merge PRs into master but none should be permitted to push directly to master. Is this possible?

like image 665
David H Avatar asked Mar 10 '17 13:03

David H


People also ask

How do I protect a master branch in Azure DevOps?

Sign in to the Azure DevOps portal, and navigate to the Repos page. Once there, choose Branches and click on the ellipsis icon on the right side of the branch that you want to protect. From the dropdown menu, click on Branch policies.

How do I bypass Azure DevOps PR?

On Bypass policies when completing pull requests change the option to Allow. The second option for setting bypass security is at the repo level. From your Project settings under Repos select Repositories and then fine the Branches node under the project you want to set the policy for.

How do I restrict push access to github?

To find it go to Settings > Branches > Branch Protection Rules and click 'Add Rule'. Then, enter the name of the branch you want to protect and click the checkbox to require pull request reviews before merging. By default, this only stops people who are not moderators.


1 Answers

Branch policies already do exactly what you're saying. When a branch policy is in place, PRs are required.

Make sure your developers don't have the "Exempt From Policy Enforcement" permission.

like image 200
Daniel Mann Avatar answered Sep 18 '22 12:09

Daniel Mann