How do you restrict force pushes to a branch in GitHub?
How do you restrict force pushes to a branch in GitHub?
Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
ICSM Computer
13-Jul-2025To 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 likemain,master, ordev.Steps to Restrict Force Pushes on GitHub
mainorrelease/*for a pattern).Result
Once this rule is applied:
git push --forceto that branch.Tip: If you want to allow normal pushes but block only force pushes: