Omniscio

OmniscioGuidesClaude Code permissions for git

Claude Code permissions: allow git but block push

Most people want Claude to commit without asking and stop at the push. This block does exactly that, and it is honest about the invocation the push rule does not catch.

Checked against Anthropic’s Claude Code permission documentation. By the Omniscio team. Updated .

The block

{
  "permissions": {
    "allow": [
      "Bash(git status)",
      "Bash(git diff *)",
      "Bash(git log *)",
      "Bash(git show *)",
      "Bash(git add *)",
      "Bash(git commit *)",
      "Bash(git switch *)",
      "Bash(git branch)"
    ],
    "ask": [
      "Bash(git push *)"
    ],
    "deny": [
      "Bash(git push --force *)",
      "Bash(git push -f *)",
      "Bash(git reset --hard *)",
      "Bash(git clean *)"
    ]
  }
}

Read it as three tiers. The allow list approves the local work. The ask list makes a push a question, which is the shape Anthropic uses in its own team example. The deny list refuses four destructive forms: a force push written flag-first, a hard reset and a clean. Because deny is evaluated before ask, those are refused rather than prompted.

Two limits on that refinement. A force flag written after the branch, as in git push origin main --force, is not matched by Bash(git push --force *) — the rule matches from the start of the command — so that form falls through to the ask. And if you would rather be asked about any force push, delete those two deny rules; the ask on git push * already covers every push.

What each rule matches

RuleMatchesDoes not match
Bash(git status)git status, which already runs without a prompt as a read-only command; the rule makes that explicitgit status --short, which needs its own rule or the read-only set to cover it
Bash(git diff *)git diff, git diff --stat, git diff main...HEADgit difftool, a different subcommand
Bash(git add *)git add ., git add -A, git add src/app.ts, and bare git addgit stash, which is a different subcommand
Bash(git commit *)git commit -m "x", git commit --amend, and bare git commitgit -C . commit -m "x", the same gap the push rule has
Bash(git switch *)git switch main, git switch -c featuregit checkout -- file, which can discard changes and is deliberately not allowed
Bash(git branch)Listing branches, because the rule has no wildcardgit branch -a as well as git branch -D feature, which deletes one
Bash(git push *)git push, git push origin maingit -C . push, git -c push.default=current push

Three facts behind the table:

  • A rule with no wildcard matches one exact command. Bash(git status) does not match git status --short. If you want the flags, write Bash(git status *). Read-only git forms such as git status and git log already run without a prompt in every mode; the allow entries make the intent visible and cover the flag forms.
  • The wildcard goes after the subcommand. Claude Code matches everything before the first * as written. Bash(git push *) is a rule about push. Bash(git *) is the broad one: it approves every git subcommand and earns a startup warning. A wildcard in the middle behaves differently again — Bash(git * push) matches only a command that ends in push, and misses git push origin main entirely.
  • Compound commands need every part allowed. git add . && git commit -m "x" runs without a prompt because both parts match. Add a push to that line, and the push still asks.

The invocation the push rule misses

Bash(git push *) matches the command text Claude writes, so it catches git push origin main. It does not catch the same operation written differently: git -C . push origin main and git -c push.default=current push origin main are different texts. Anthropic says this plainly, and pairs it with the same warning for curl and rm: a Bash rule covers the invocation Claude usually produces and is not a security boundary around the program.

What happens to the uncovered form depends on your permission mode. In Manual mode it prompts, because nothing matches. In acceptEdits or auto, the mode decides, and nothing in this block holds that push back. That is why the block is about reducing noise on the commands you trust, not about guaranteeing a push never happens.

When the guarantee matters, Anthropic points to the same two tools it points to elsewhere: sandboxing for OS-level enforcement, and a PreToolUse hook that can inspect the full command and refuse it. A hook can also close the general gap, because it sees the command before the rule does.

Where the block goes

Commit it at .claude/settings.json if the team agrees; keep it in .claude/settings.local.json if it is your habit. In a project file, the allow rules wait until each person accepts the workspace trust dialog for the folder, while the ask and deny rules apply regardless.

For one session, --allowedTools "Bash(git commit *)" adds the allow rule without editing a file, and --disallowedTools "Bash(git push *)" turns the push prompt into a refusal. Deny rules from any settings file still outrank a flag.

The four files and their precedence are on the settings.json locations page.

Confirm it took effect

  1. Run /permissions and check that the eight allow rules, the push ask and the four denials are listed, with the settings file that supplied each.
  2. Ask Claude to run git add . && git commit -m "test". No prompt.
  3. Ask it to run git push. A prompt, or a refusal if you moved push to deny.
  4. Ask it to run git reset --hard. Refused.

Claude Code watches settings files and reloads them, so a saved edit usually reaches a running session without a restart. /status shows which settings files loaded; claude doctor lists rules Claude Code rejected.

The common mistake

Writing Bash(git push*). With no space before the wildcard it is not the same rule as Bash(git push *): it matches git push and git push origin main, and it also matches a command that merely begins with the letters git push, such as git pushmirror sync.

Writing Bash(git *) instead of naming subcommands. Asking and denying still outrank it, so your push rule keeps working, but it silently approves git reset, git clean and every other subcommand you never listed.

Assuming the rule follows the program. It follows the text. A push written with -C, or wrapped in sh -c, is a different command to the matcher, and no number of added prefixes changes that.

Where these answers come from

  • What a Bash rule matches, the wildcard rules, and the forms a push rule misses: Configure permissions, read November 25, 2026.
  • The team example that puts Bash(git push *) in ask: Example settings files.
  • Deny before ask before allow: the same permissions page, “Manage permissions”.
  • The one-session flags: CLI reference.

Common questions

Should git push be an ask rule or a deny rule?

Ask, if you want to review each push: the prompt shows the command and you decide. Deny, if the session should never push at all. Deny is evaluated first, so it wins if both are present.

Does Bash(git push *) stop a force push?

It matches git push --force as a push, so the ask rule catches it. The block’s deny rules refuse the flag-first spelling outright, because deny is evaluated before ask; a force flag written after the branch falls through to the ask.

Why not just allow Bash(git *)?

Because it approves every git subcommand, so reset and clean stop asking, and Claude Code warns at startup about an allow rule with a wildcard before the subcommand. Your ask and deny rules still hold push back, but name the subcommands you trust rather than relying on that.

What about git commit hooks?

A hook runs inside the git command, so the matcher sees only git commit ...; the rule approves the commit, not what the hook does afterwards. To bound a hook’s writes, use sandboxing, which covers shell commands and their child processes.