October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Block `git push –force` in Claude Code with a Deny Rule

Add a Bash deny rule in `.claude/settings.json` to block matching `git push --force` commands in Claude Code, with important coverage limits explained.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.