Claude Code Secretly Resets Git Changes Every 10 Minutes
Claude Code version 2.1.87 on macOS automatically runs git fetch origin and git reset --hard origin/main every 600 seconds. This results in the loss of all uncommitted changes in tracked files in the repository. A developer recorded more than 95 such operations over 36 hours across four sessions using git reflog.
Reproduction confirmed the issue: changes in tracked files are rolled back exactly 10 minutes later, while untracked files remain untouched. Filesystem monitoring revealed the creation of lock files in .git/refs/remotes/origin/HEAD and .git/refs/heads/main without launching any external git processes. The operations are baked into the Claude Code process, likely via libgit2.
Investigating the Cause
External factors ruled out: git hooks, cron jobs, cloud sync services, IDEs, Time Machine, file watchers, plugins. The only process with access is Claude Code running with the --dangerously-skip-permissions flag. The time offsets in reflog are consistent within a session but vary between runs, pointing to an internal timer.
The CHANGELOG mentions CLAUDE_CODE_DISABLE_CRON to disable periodic tasks. The bug goes unnoticed with frequent commits—Claude Code encourages them, rendering the reset harmless. The problem surfaces during extended work with WIP changes: at least 3 edits lost in 2 hours.
Similar complaints on GitHub lack deep analysis. Anthropic hasn't commented yet.
How to Check and Protect Yourself
Check the reflog:
git reflog | grep "reset: moving to origin"
Look for entries spaced 10 minutes apart.
Protection measures:
- Commit changes every 5–7 minutes.
- Use git worktrees: they're fully isolated from the reset.
- Run with
CLAUDE_CODE_DISABLE_CRON=1to disable the internal cron.
Worktrees are created like this:
git worktree add ../project-worktree main
Switching between them prevents data loss.
Key Points
- Automatic reset every 10 minutes: wipes uncommitted changes in tracked files.
- Internal timer: tied to session startup, controlled by
CLAUDE_CODE_DISABLE_CRON. - Reproducible on macOS 2.1.87: libgit2 without external processes.
- Worktrees as a solution: complete immunity to the bug.
- Check reflog: the key to diagnosis in your project.
— Editorial Team
No comments yet.