# Ensure default branch deletion is not allowed

- Source: https://support.icompaas.com/support/solutions/articles/a_1790019222558994-ensure-default-branch-deletion-is-not-allowed
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [Version Control System (VCS)](https://support.icompaas.com/support/solutions/c_1781179095087930) › [GitHub](https://support.icompaas.com/support/solutions/folders/f_1781179116560328)
- Last updated: 2026-09-21
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

**Description**

Ensure a ruleset on the repository's default branch prevents that branch from being deleted.

**Rationale**

The default branch is typically the primary source of truth for the codebase and the target of CI/CD pipelines and deployments. Deleting it, whether by accident or through a compromised account, causes an immediate and severe availability impact.

**Impact**

-   Prevents accidental or malicious deletion of the repository's default branch
    
-   Protects the primary source of truth for the codebase and its history
    
-   Prevents CI/CD pipelines and deployments tied to the default branch from breaking unexpectedly
    
-   Reduces the impact of a compromised account with push access
    

**Default Value**

By default, a repository with no ruleset targeting its default branch has no restriction on deleting that branch; anyone with sufficient permissions can delete it.

**Pre-Requisites**

-   Admin access to the repository
    

**Test Plan**

1.  Sign in to GitHub at [https://github.com](https://github.com/).
    
2.  Select the relevant repository.
    
3.  Click Settings.
    
4.  In the "Code, planning, and automation" section of the sidebar, click Rulesets.
    
5.  Select the ruleset that targets the default branch.
    
6.  Verify that Restrict deletions is enabled.
    

7.  If Restrict deletions is not enabled, or no ruleset targets the default branch, follow the implementation steps.
    

**Implementation Steps**

1.  Sign in to GitHub at [https://github.com](https://github.com/).
    
2.  Select the relevant repository.
    
3.  Click Settings.
    
4.  In the "Code, planning, and automation" section of the sidebar, click Rulesets.
    

5.  Select the existing ruleset that targets the default branch, or click New ruleset, then New branch ruleset.
    
6.  Under Ruleset Name, enter a name, and set Enforcement status to Active.
    
7.  Under Target branches, click Add target, then select Include default branch.
    
8.  Under Rules, enable Restrict deletions.
    

9.  Click Create or Save changes.
    

**Backout Plan**

1.  Sign in to GitHub at [https://github.com](https://github.com/).
    
2.  Select the relevant repository.
    
3.  Click Settings.
    
4.  In the "Code, planning, and automation" section of the sidebar, click Rulesets.
    
5.  Select the ruleset that targets the default branch.
    
6.  Disable Restrict deletions.
    
7.  Click Save changes.
    

**Reference**

-   [https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets)
    
-   [https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets)

## Related compliance guidance

- [SOC 2 compliance: a practical implementation guide for cloud-native SaaS teams](https://support.icompaas.com/compliance/soc-2-trust-services-criteria): Configuration checks like this one are the technical half of a SOC 2 / ISO 27001 programme — the guide shows where they fit, what else an auditor expects, and how to evidence them.
- [ISO/IEC 27001:2022 compliance: a practical implementation guide](https://support.icompaas.com/compliance/iso-27001-2022): ISO 27001 Annex A.8 (technological controls) is where cloud hardening evidence lands; the guide shows how to run the ISMS around it.
