claude-code
claude-code copied to clipboard
[MODEL] Claude uses git --amend without warning, then gives incorrect push instructions
Preflight Checklist
- [x] I have searched existing issues for similar behavior reports
- [x] This report does NOT contain sensitive information (API keys, passwords, etc.)
Type of Behavior Issue
Other unexpected behavior
What You Asked Claude to Do
push and summarize what we did today
What Claude Actually Did
- Used git commit --amend multiple times during session without asking permission or warning about implications
- When sandbox network blocked push, Claude said: "Try git push when your network is back"
- This caused divergent branches because amended commits require --force-with-lease
- User had to deal with rebase conflicts and force push manually
Expected Behavior
- Ask before using git commit --amend since it rewrites history
- When handing off git operations after amending, provide correct command: git push --force-with-lease
- Explain that amended commits create new hashes and require force push
Files Affected
Git history (multiple commits amended)
Permission Mode
Accept Edits was ON (auto-accepting changes)
Can You Reproduce This?
Haven't tried to reproduce
Steps to Reproduce
- Have Claude make a commit
- Ask Claude to fix something small
- Claude uses --amend without asking
- Claude's sandbox can't push
- Claude tells user to run git push (wrong command)
Note: I haven't tried to reproduce this exact issue, but many times VM cannot push and ends up in a mess.
Claude Model
Opus
Relevant Conversation
> push and summarize what we did today
⏺ Bash(git push)
⎿ Error: Exit code 128
ssh: Could not resolve hostname github.com: -65563
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
⏺ Network is down. You can push later with git push. Here's what we accomplished today:
...
⏺ Bash(git add docs/patterns.md && git commit --amend --no-edit)
⎿ [main dafdb82] docs: add Azure PWA patterns guide for reuse across projects
Date: Sat Jan 3 09:57:31 2026 +1000
2 files changed, 463 insertions(+)
create mode 100644 docs/patterns.md
⏺ Added the NPM workspaces pattern to docs/patterns.md as an advanced section. Key points documented:
- Two "shared" directories pattern (NPM package vs backend-only)
- Setup configuration (package.json, tsconfig references)
- When to use (larger projects needing shared types)
Try git push when your network is back.
...
And in a separate terminal I ran the following command:
% git push
To github.com:example/example.git
! [rejected] main -> main (non-fast-forward)
And then I pulled thinking someone else pushed code and ended up with a merge conflict.
Impact
Medium - Extra work to undo changes
Claude Code Version
2.0.76 (Claude Code)
Platform
Anthropic API
Additional Context
Claude made up a false claim that "CLAUDE.md explicitly states" something about git amend - this was not true and is another example of problematic behavior in this session.