To block Bash commands that begin with git push --force, add a deny rule to your project’s .claude/settings.json. This is a Claude Code permission control for that command prefix—not a guarantee that every possible way of force-pushing is blocked.
How do I block git push --force in Claude Code?
Add this rule under permissions.deny in the project’s .claude/settings.json file:
As an Amazon Associate I earn from qualifying purchases.
{
"permissions": {
"deny": [
"Bash(git push --force:*)"
]
}
}
Claude Code uses permission patterns in the form Tool(optional-specifier). For Bash, the :* suffix is the documented way to match a command prefix followed by additional command text. The specific git push --force:* pattern above is constructed from that syntax; Anthropic does not present it as a ready-made force-push example. See Anthropic’s permission rules documentation.
Save the file, then use Claude Code in the project. Deny rules prevent matching tools from being used and take precedence over allow rules. Anthropic describes Claude Code permissions as a way to configure tool access alongside Bash approval prompts in its security guidance.
#1 Best Overall
What does this rule match—and what does it not establish?
Use this pattern for Bash commands beginning with the literal sequence git push --force. The documented prefix-pattern syntax does not, by itself, establish coverage for other ways of expressing a force push.
git push -f- Shell aliases or other command substitutions
- Commands with altered argument order
- Commands prefixed with options such as
git -C - Equivalent Git actions invoked through a tool other than Bash
If those variants matter, verify matching behavior with the Claude Code version in use and add controls appropriate to the broader policy. This rule alone should not be treated as a repository-wide guarantee that force-pushes are impossible.
Rank #2
Can I use --disallowedTools instead?
Claude Code also documents --disallowedTools as a command-line restriction that works in addition to settings files. The project rule is saved in project configuration; the CLI option is supplied when launching Claude Code. Choose based on whether the restriction should travel with the project or apply to a particular invocation. The CLI reference documents the option and its relationship to settings files.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Why add a force-push guardrail?
Anthropic’s prompting best practices identify “git push –force” among hard-to-reverse operations, alongside hard resets and amending published commits. A deny rule helps prevent Claude Code from issuing the matching Bash command without an explicit decision to change the restriction.
Quick Recap
Best Value
Rank #4
Rank #3
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




