What a force push does to reviewed history#
A normal push only adds commits on top of what the branch already has. A force push moves the branch to any commit, so commits that were on the branch can drop out of its history. GitHub's documentation names the review risk directly: "Force pushing can also be used to delete branches or point a branch to commits that were not approved in a pull request." Block force pushes
The following run uses a throwaway repository with a bare origin on disk, so it demonstrates Git's behavior, not GitHub's. A reviewed change raised a rate limit to 200 and reached main. Bob cloned it. Then Alice reset her copy and committed a different value under the same message. Output is trimmed to the relevant lines:
$ git log --oneline origin/main
e9a5e59 Raise limit to 200
ae144b3 Add rate limit config
$ git push origin main
! [rejected] main -> main (non-fast-forward)
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
$ git push --force origin main
+ e9a5e59...399530d main -> main (forced update)
$ git log --oneline origin/main
399530d Raise limit to 200
ae144b3 Add rate limit config
$ git show origin/main:config.txt
limit = 100000
The history still reads "Raise limit to 200", but the file now says 100000. The reviewed commit is still in the remote's object store, and no branch contains it:
$ git cat-file -t e9a5e59
commit
$ git branch --contains e9a5e59
$ git diff e9a5e59 399530d
-limit = 200
+limit = 100000
Bob, who based his work on the reviewed commit, finds out on his next pull:
(bob) $ git pull --no-rebase origin main
+ e9a5e59...399530d main -> origin/main (forced update)
CONFLICT (content): Merge conflict in config.txt
The rejected plain push in the middle is Git's own fast-forward check. Blocking force pushes on GitHub removes the --force override for everyone the rule covers.
Nothing else in a typical review policy would notice. CI runs on the new commit and may pass, since 100000 is a valid number. No pull request exists for the new commit, so no reviewer is asked, and the approval on the original pull request was given to a commit the branch no longer contains. Deleting a branch and pushing a new one under the same name has the same effect, which is why the two protections go together.
What GitHub provides#
For classic branch protection, "By default, each branch protection rule disables force pushes to the matching branches and prevents the matching branches from being deleted." You can turn on Allow force pushes, either for "everyone with at least write permissions to the repository" or for specific people or teams, and Allow deletions, which lets "anyone with at least write permissions" delete the branch. About protected branches Allow force pushes sits under "Rules applied to everyone including administrators." Managing a branch protection rule
In a ruleset, Block force pushes "is enabled by default" and Restrict deletions "is selected by default." Only actors on the ruleset's bypass list are exempt. Available rules for rulesets Allowing force pushes leaves the other rules in place: "Enabling force pushes will not override any other rules. For example, if a branch requires a linear commit history, you cannot force push merge commits to that branch."
For a fictional repository, acme/payments-api, a ruleset that covers the default branch and release branches looks like this in the REST API:
{
"name": "default and release branches: no rewrites",
"target": "branch",
"enforcement": "active",
"bypass_actors": [],
"conditions": {
"ref_name": { "include": ["~DEFAULT_BRANCH", "refs/heads/release/**/*"], "exclude": [] }
},
"rules": [
{ "type": "non_fast_forward" },
{ "type": "deletion" }
]
}
~DEFAULT_BRANCH is the API's name for the default branch, and release/**/* matches every branch under release/, as the documentation's releases/**/* example shows. About rulesets
The cost#
On a branch that only receives merged pull requests, nobody needs to force push, so the ongoing cost is close to zero. The cost appears in rare cases.
The first is removing something from history, such as a committed secret or a large file. That needs a rewrite. Grant it as a temporary bypass for the person doing the cleanup, then remove the bypass, rather than leaving Allow force pushes on. Rotating the secret matters more than the rewrite anyway, as the push protection guide explains.
The second is renaming the default branch. The ruleset documentation warns: "If force pushes are blocked, organization owners or repository administrators will be unable to change or rename the default branch unless they are authorized to bypass the ruleset."
Do not extend the rule to pull request branches. Authors rebase and force push their own branches routinely, and blocking that adds churn without protecting reviewed history, because the history that matters is what reaches the protected branch.
What blocking force pushes does not catch#
The rule stops history being rewritten. It does not stop new, unreviewed commits being added on top. Anyone with push access can still push a fast-forward commit to the branch unless the branch also requires a pull request. The rule also says nothing about the pull request branch before merge, where a force push after approval can swap the approved commits. That case belongs to dismissing stale approvals, which dismisses an approval when the diff changes. Tags need their own ruleset, covered in the release tag guide.
The decision#
Keep force pushes blocked and deletion restricted on the default branch and every release branch pattern. Leave the bypass list empty for these two rules, and grant a dated, temporary bypass when a history rewrite is truly needed. Pair the rule with a required pull request and at least one required approval, so the only way onto the branch is an approved merge. A required pull request alone does not require anyone to approve it.