Claude force-pushed over existing private GitHub repo without user permission
Summary
During a session where Claude was setting up private GitHub repos for multiple project folders, it force-pushed over an existing repo that already had history, replacing it with a single fresh commit. This was done without asking for permission and destroyed the existing commit history.
Steps to Reproduce
- Ask Claude to create private GitHub repos for several project folders on a remote server
- One of the projects already had a GitHub repo with existing commits
- Claude ran
git init,git add -A,git commiton the server (creating a new root commit) - The initial
git pushwas rejected because the remote had divergent history - Claude attempted
git pull --rebase, which hit a merge conflict - Claude then ran
git rebase --abortfollowed bygit push --force, overwriting the entire remote history
What Happened
The remote repo went to a single commit:
b3236a2 Initial automem-hooks setup
The original history was destroyed on the remote.
Expected Behaviour
When the initial push was rejected with "Updates were rejected because the remote contains work that you do not have locally", Claude should have:
- Stopped and explained the conflict to the user
- Asked how the user wanted to proceed (merge, rebase, or skip this repo)
- Never used
--forcewithout explicit user authorisation
Force-push is a destructive, hard-to-reverse operation. Claude's own system instructions state that destructive operations affecting shared systems should require user confirmation before proceeding.
Why This Is Serious
- Data loss: The remote commit history was destroyed.
- No permission requested: At no point did Claude ask "Can I force-push?" or warn about the consequences.
- Cascading decisions: Claude made a series of increasingly destructive choices (init over existing repo -> rebase -> abort -> force push) without pausing to check in.
- Trust: Users need to be confident that Claude will not destroy their work. A git repo is one of the most important things a developer has.
Environment
- Claude Code CLI
- Model: claude-opus-4-6
- OS: Linux (WSL2) connecting to a Linux Mint server via SSH
- Date: 2026-03-11
Suggested Fix
git push --forceshould always require explicit user confirmation, similar to how other destructive operations are handled- When a push is rejected due to divergent history, Claude should explain the situation and present options rather than autonomously escalating to force-push
- Consider adding force-push to a blocklist of commands that cannot be executed without user approval
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗