---
title: "How do you restrict force pushes to a branch in GitHub?"  
description: "How do you restrict force pushes to a branch in GitHub?"  
author: "ICSM Computer"  
published: 2025-07-10  
updated: 2025-07-13  
canonical: https://www.mindstick.com/forum/161810/how-do-you-restrict-force-pushes-to-a-branch-in-github  
category: "GitHub"  
tags: ["github", "git"]  
reading_time: 2 minutes  

---

# How do you restrict force pushes to a branch in GitHub?

**How do you restrict force pushes to a [branch](https://answers.mindstick.com/qa/41075/why-did-the-continental-congress-adopt-the-olive-branch-petition) in [GitHub](https://www.mindstick.com/forum/34563/bitbucket-vs-github-vs-gitlab)?**

## Replies

### Reply by ICSM Computer

To **restrict force pushes to a branch** on GitHub, you can use **branch protection rules**. These rules prevent destructive actions like force-pushes (`git push --force`) to important branches like `main`, `master`, or `dev`.

### Steps to Restrict Force Pushes on GitHub

- **Go to your repository** on GitHub.
- Click on **Settings** (you must have admin access to the repo).
- In the left sidebar, click **Branches**.
- Under **Branch protection rules**, click **"Add rule"**.
- In the **Branch name pattern**, enter the name of the branch you want to protect (e.g., `main` or `release/*` for a pattern).
- Enable the checkbox:

   - ✅ **"Do not allow force pushes"**

- (Optional) Enable other protections like:

   - **Require pull request reviews**
   - **Require status checks to pass**
   - **Require linear history**

- Click **Create** or **Save changes**.

### Result

Once this rule is applied:

- All users will be **blocked from using** `git push --force` to that branch.
- GitHub will return an error like:

> *"You cannot force push to a protected branch."*

### Tip: If you want to allow normal pushes but block only force pushes:

- Don’t enable **“Restrict who can push to matching branches”** (unless you also want to control who can push).
- Just enable **“Do not allow force pushes.”**


---

Original Source: https://www.mindstick.com/forum/161810/how-do-you-restrict-force-pushes-to-a-branch-in-github

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
