What is protected git branch?

无人久伴 提交于 2019-12-24 05:05:15

问题


I am new with GIT and branching and recently I saw protected branch, what does that mean and how do we protect a branch?


回答1:


It's not a feature of git but a feature of Github and other code hosting sites. It allows you to protect specific branches from unauthorized modification.

Here's the Github documentation::

Protected branches ensure that collaborators on your repository cannot make irrevocable changes to branches. These branches can also be protected by requiring pull requests to have at least one approved review before they can be merged.

If you own a repository with multiple collaborators who create branches and open pull requests, you may need to enforce branch protections to keep your project and pull requests organized and safe.

Protected branches block several features of Git on a branch that a repository administrator chooses to protect. A protected branch:

Can't be force pushed

Can't be deleted

Can't have changes merged into it until required status checks pass

Can't have changes merged into it until required reviews are approved Can't be edited or have files uploaded to it from the web

Can't have changes merged into it until changes to files that have a designated code owner have been approved by that owner If your repository belongs to an organization, you can restrict users or teams from pushing to a protected branch.

The specific details will vary depending on the website you use.




回答2:


tools like github, gitlab etc. gives you an option to protect branches against accidental messing ups. non authorized users cannot push changes to protected branches



来源:https://stackoverflow.com/questions/48029867/what-is-protected-git-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!