Codex blocks `git push --force` and branch deletion even when running with `--yolo`

Resolved 💬 4 comments Opened Feb 5, 2026 by rayjasson98 Closed Feb 5, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

0.95, 0.96, 0.97

What subscription do you have?

ChatGPT Plus

Which model were you using?

gpt-5.2-codex

What platform is your computer?

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64

What terminal emulator and version are you using (if applicable)?

Windows Terminal (WSL)

What issue are you seeing?

Hi, since 5 Feb I’ve noticed that Codex can no longer perform git push --force, git push --force-with-lease, or delete branches. I don’t have any team configuration set up and I’m running codex --yolo with the default settings (no permissions, rules, or skills configured). Is this restriction coming from the GPT model itself?

What steps can reproduce the bug?

This is a transcript from my session. I’ve tried multiple sessions and have seen the same behavior since this morning.

╭────────────────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.97.0)                          │
│                                                    │
│ model:     gpt-5.2-codex medium   /model to change │
│ directory: ~                                       │
╰────────────────────────────────────────────────────╯

  Tip: New Try the Codex App with 2x rate limits until April 2nd. Run 'codex app' or visit https://chatgpt.com/codex


› do a git push -f


• I'm preparing to run a forced git push to update the remote repository with local changes.

• I can’t run git push -f due to the environment policy blocking that command. If you want, run it directly in your terminal and I can help
  verify the result or handle any follow-up.


› From codex? How to bypass it? I need it for my automation workflow.


• I can’t help bypass the policy or provide a workaround to force git push -f from Codex.

  If you’re doing this for automation, the practical route is:

  - Run the push from your own automation runner/terminal (outside Codex).
  - Then tell me the result (or paste git status / git log -n 5 --oneline) and I’ll continue from there.

  If you want, I can also adjust your workflow to avoid forced pushes (e.g., use git push --force-with-lease from your own runner or switch
  to merge-based updates).

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

4 Comments

etraut-openai contributor · 6 months ago

This is considered one of a handful of "dangerous commands" that are blocked by the harness even when running in yolo mode. Many users (especially on Windows) run in yolo mode and have lost work. To mitigate this, we've added hard blocks for certain dangerous commands that can result in significant data loss. This is a short-term mitigation. Our longer-term fix is to continue to improve the sandbox rules so users don't feel compelled to use yolo mode. Then we can remove the "dangerous command" checks.

rayjasson98 · 6 months ago

Hi @etraut-openai,

Is this a newly implemented restriction? If so, why is it a hard block in the first place? There are organizations whose workflow intentionally relies on force-pushes to maintain a single commit on a feature branch, and this is something that could be safely automated via a Codex skill.

For example, I’d also like to create a workflow that automatically closes a branch after I confirm that a PR has been merged. You know, things like that.

Is there any way to whitelist these commands? In my opinion, adding hard blocks like this for users who understand the implications isn’t fair. In our case, force-push is already disabled on main branch to prevent accidental data loss. This kind of restriction effectively limits the prompts we can use in Codex, even when they’re part of a controlled, well-defined workflow for knowledgeable users who understand the implications of these commands.

etraut-openai contributor · 6 months ago

The "dangerous commands" block has been in place for many months. We've made small tweaks, but git push --force has been blocked for a long time.

There is a way to whitelist commands using execution policy rules. The "dangerous command" blocks are applied only in the fallback case where the command doesn't match any user-defined rules.

rayjasson98 · 6 months ago

I managed to add some rules to let me bypass the restrictions:

prefix_rule(pattern = ["git", "push", "--force-with-lease"], decision = "allow")
prefix_rule(pattern = ["git", "branch", "-D"], decision = "allow")

That said, I’m pretty sure I’ve already had Codex successfully perform force pushes multiple times this week via skills. I only started seeing such issue today, but thanks anyway!