简体   繁体   中英

How to protect master branch in git from merge

For example, I have feature branch and master branch locally. Now, I have created a file in feature branch and I don't want to merge to master but some how accidentally merged. So, next time on wards I don't want to merge master and protect the master branch from being merge.

If you just want the merge can be completed successfully with some review, you can set branch policy for this master.

在此处输入图片说明

At this time, the process of merge into master will have some precondition, including 2 approval needed, build validation or work item state limited and etc. Without these validation, the pull request will not be completed successfully. Meanwhile, the merge will not be applied. As normal, this is a more standardized process.

Note: While you choose this method, please deny the permission of the follow pic mentioned. Or other users will bypass the validation you configured to push change into master:

在此处输入图片说明

In addition, if what you want is that don't want anyone to change master branch, even with validation. You can configure the security of master branch. Please set Contribute as Deny .

在此处输入图片说明

At this time, even all of validation is satisfied, the change still could not be merged into master.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM