# Enabling Branch protection:

### Creating a branch inside repository:

* Go to the repository and click on **new branch.**

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-4266a9eee4f85333cd5b7a783c2d9f7f029495c0%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

* Here I have created a branch named **DIGIT**
* After, go to that branch in the same repository.

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-30b859f2cee0be06c52fd4076d9f35158dfce3f8%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Creating branch protection rule:

* Branch protection rule states that, how to manage the branch restrictions/permissions in GitHub.

NOTE : You must have admin access orelse you have to be a codeowner to make these changes for branch restrictions/permissions.

* Open <https://github.com> and choose any repository.Go to the main page. Click on **settings.**

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-59dedb87610065c5eac3f185844897468134c4de%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

* Click on **branches**

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-18b267848667dec715b5b912140488cb5d87a459%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

* If you click on the **Edit** rules you can able to see the rules which are applied for that branch.you should follow the rules when ever you are going to made any changes to that branch and pushing it.
* If you want to create new branch protection rule click on **Add Rule.**

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-cf26a1743f478773fa25bb54cdf039996ac9f0e8%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

The common restrictions we are following to merge branches are :

1.Requires pull request

2.Requires approvals from CODE OWNERS

* Only the **CODE OWNERS** can have access to merge and makes changes to these rules.
