Claude Code defaults to rebase+force-push instead of merge when updating branches
Resolved 💬 4 comments Opened Mar 9, 2026 by williamjameshandley Closed May 1, 2026
Problem
When Claude Code needs to update a branch with changes from the base branch, it defaults to git rebase followed by git push --force-with-lease, even when operating on someone else's PR branch. This is destructive: it rewrites commit history and breaks the other contributor's local checkout.
Expected behavior
- Default to
git mergewhen updating a branch with upstream changes — it's non-destructive and preserves history - Never force-push to a branch without explicit user approval
- When fixing CI on someone else's PR, just commit the fix and
git push— don't rewrite their history at all
What happened
The bot was asked to fix a CI failure (formatting) on another contributor's PR. It:
- Committed the fix (correct)
- Rebased the branch onto the base branch (unnecessary, destructive)
- Force-pushed to the contributor's remote branch (violated its own instructions)
The contributor now cannot git pull normally — they need git reset --hard to recover.
Claude Code's own instructions say
"NEVER run destructive git commands (push --force, reset --hard, ...) unless the user explicitly requests these actions"
Despite this, the bot chose rebase+force-push as its default strategy. This appears to be a trained-in bias toward rebase over merge across LLM coding agents generally.
Suggested fix
- When a branch needs updating with the base branch, always use
git merge, notgit rebase - Treat
git rebaseas a destructive operation requiring explicit user approval, same aspush --force - When working on someone else's branch, minimize history changes — commit the fix and push, nothing more
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗