Skip to content

Latest commit

 

History

History
68 lines (37 loc) · 3.99 KB

File metadata and controls

68 lines (37 loc) · 3.99 KB

Managing a branch protection rule

you can create a branch protection rule to enforce certain workflows for one or more branches, such as requiring an approving review or passing status checks for all pull requests merged into the protected branch.

NOTE

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server.

1-About branch protection

You can create a branch protection rule in a repository for a specific branch, all branches, or any branch

2-Creating a branch protection

On main page of the repository, Under your repo. click Settings. In section of the sidebar, click Branches. Next to "Branch protection rules", click Add rule.

chrome_aRWYroM58K

Under "Branch name pattern", type the branch name or pattern you want to protect Under "Protect matching branches", select Require a pull request before merging.

PR-reviews-required-updated

Optionally, to require approvals before a pull request can be merged, select Require approvals, click the Required number of approvals before merging drop-down menu, then select the number of approving reviews you would like to require on the branch.

number-of-required-review-approvals-updated

Optionally, to dismiss a pull request approval review when a code-modifying commit is pushed to the branch, select Dismiss stale pull request approvals when new commits are pushed.

PR-reviews-required-dismiss-stale

Optionally, to require review from a code owner when the pull request affects code that has a designated owner, select Require review from Code Owners.

Optionally, to require review from a code owner when the pull request affects code that has a designated owner, select Require review from Code Owners.

Optionally, to allow specific actors to push code to the branch without creating pull requests when they're required, select Rules applied to everyone including administrators. Then Click on Allow force pushes,ans select Specify who can force push. NOW, search for and select the actors who should be allowed to skip creating a pull request.

chrome_yEyeISXBoF

and click to Create.

Send the commit on main protection branch it will pending.

chrome_tl9dIqqHNQ

on the admin user site recived the pull request on commit the code

image

now view the changes and approve it.

image (1)

now you can merge the request, on the specific branch ,i used the main.

image (2)

now its all done , noew you have the option to delete the branch which is tempraraliy created ranch formate like (username_patch_no.#)

image (3)

additional links for slides view: LINK:https://dev.to/syedasadrazadevops/how-to-protect-specific-branch-merge-on-git-push-43e9