My automated tool is running git reset --hard origin/main in my project every 10 minutes
Update (2026-03-30): Root cause identified — this was NOT a Claude Code bug. The resets were caused by a separate tool I built that was running locally, which used GitPython to hard-reset the working directory on a poll cycle. The evidence was misleading because the tool shared the same CWD and monitored projects CC was working on. See my comment below for full details. Apologies for the false report.
Summary
Claude Code performs git fetch origin + git reset --hard origin/main on the user's project repo every 10 minutes via programmatic git operations (no external git binary spawned). This silently destroys all uncommitted changes to tracked files. Untracked files survive. Git worktrees are immune.
Environment
- Claude Code version: 2.1.87 (Homebrew cask, compiled Bun binary)
- OS: macOS 15.4 (Darwin 25.3.0, arm64)
- Shell: zsh
Evidence
1. Git reflog: 95+ entries at exact 10-minute intervals
e8ea2c9 HEAD@{2026-03-29 22:19:09 +0200}: reset: moving to origin/main
e8ea2c9 HEAD@{2026-03-29 22:09:09 +0200}: reset: moving to origin/main
e8ea2c9 HEAD@{2026-03-29 21:59:09 +0200}: reset: moving to origin/main
e8ea2c9 HEAD@{2026-03-29 21:49:09 +0200}: reset: moving to origin/main
...
8792b6c HEAD@{2026-03-29 16:55:41 +0200}: reset: moving to origin/main
8792b6c HEAD@{2026-03-29 16:45:41 +0200}: reset: moving to origin/main
...
32aa7c7 HEAD@{2026-03-28 15:47:36 +0100}: reset: moving to origin/main
32aa7c7 HEAD@{2026-03-28 15:37:36 +0100}: reset: moving to origin/main
The second offset is consistent within each session but varies between sessions (:08, :36, :41, :09), confirming a timer tied to session start time with a 600-second interval. 95+ entries observed across 4 sessions over ~36 hours.
2. Live reproduction
- Modified
src/lib/api.ts(tracked file) and created.canary-test.txt(untracked file) - Monitored every 15 seconds
- At the next 10-minute mark,
api.tssilently reverted — modification gone .canary-test.txt(untracked) survived- Reproduced consistently across 4 consecutive cycles
3. fswatch caught the file operations
At the exact reset time, fswatch on .git/ captured:
23:59:10.349 .git/refs/remotes/origin/HEAD.lock Created IsFile Removed AttributeModified
23:59:10.352 .git/logs/HEAD IsFile Updated
23:59:10.354 .git/refs/heads/main.lock Created IsFile Removed AttributeModified
This is the classic pattern for git fetch origin + git reset --hard origin/main.
4. Only the Claude Code process is a candidate
lsof confirms the Claude Code CLI process (PID 70111, claude --dangerously-skip-permissions) is the only process with CWD in the affected repo. Two other Claude CLI sessions are in different directories.
5. No external git binary spawned
Process monitoring at 0.1-second intervals found zero git processes around reset times. The operations are programmatic (libgit2 or similar) within the Claude Code process, confirmed by .git/ lock file creation without any external process.
6. Worktrees are immune
The worktree reflog shows zero reset: moving to origin entries. The reset targets the main working tree only.
What was ruled out
A thorough investigation eliminated all external causes:
| Cause | Verdict | Detail |
|-------|---------|--------|
| Git hooks | Cleared | All .sample (inactive). No husky/lint-staged. |
| Claude Code user hooks | Cleared | Only peon-ping (audio). None reference git. |
| Plugin marketplace updater | Disproven | Deleted ~/.claude/plugins/marketplaces/ — resets continued unchanged. |
| macOS cloud sync | Cleared | No sync tool covers this directory (checked iCloud, Dropbox, Syncthing, Synology, Google Drive). |
| Cron/LaunchAgents | Cleared | No crontab. No LaunchAgent does git operations on this path. |
| Vite/SvelteKit dev server | Cleared | All file writes go to output dirs. Zero git awareness in source. |
| IDE/editors | Cleared | nvim in different repo. No format-on-save. |
| Time Machine | Cleared | Local snapshots are read-only APFS. |
| File watchers | Cleared | No fswatch/entr/watchman/guard running. |
Binary analysis (partial)
From the compiled binary at /opt/homebrew/Caskroom/claude-code/2.1.87/claude:
hg1()function does["fetch","origin"]viat_(C8(), _)without explicit CWD, defaulting toprocess.cwd()io1()function is a git pull wrapper logginggit pull: cwd=${H} ref=${_??"default"}fileHistorystate tracks{snapshots: [], trackedFiles: new Set, snapshotSequence: 0}- The exact timer/setInterval setup could not be identified in minified code
Impact
Any uncommitted changes to tracked files in the main working tree are silently destroyed every 10 minutes. During a 2-hour session, changes had to be re-applied 3+ times before the cause was identified. The bug is invisible when all changes are committed (the reset is a no-op), making it appear intermittent.
Question for the Claude Code team
What internal mechanism runs git fetch origin + git reset --hard against process.cwd() every 600 seconds? This could not be determined from the outside due to the compiled binary and lack of sudo for process tracing.
Workarounds
- Use git worktrees — confirmed immune (zero reset entries in worktree reflog)
- Commit frequently — committed changes survive the reset
Related issues
- #8072 — "Critical Bug: Code Revisions Being Repeatedly Reverted"
- #7232 — "CRITICAL: Claude executed git reset --hard without authorization causing data destruction"
- #32793 — "
claude installcorrupts project git remote URL" (marketplace git in wrong directory — related but not this specific bug)
21 Comments
Can you ask Claude what is inside
MEMORY.md, all.claude/including at~/.claude, and any that might be in subfolders? Then ask Claude to search or usegrepforsleepand600in those folders and . Then search your code base for600.There could be a stray artifact that got written by accident. I would rule that out first.
Also, it might be a rogue agent.
<img width="1018" height="445" alt="Image" src="https://github.com/user-attachments/assets/021ffb29-2b22-4c80-aadd-1f18bba4e884" />
This issue illustrates something deeper than a timer misconfiguration.
The root cause isn't the specific command — it's that the agent acted without pre-authorization, repeatedly, on your project. Whether Claude Code had a misconfigured timer or intentional sync logic, the structural gap is the same: an agent executing destructive, irreversible commands dozens of times without an approval record.
I wrote about why this pattern keeps recurring and what an approval gate would have changed: https://agentlair.dev/blog/claude-code-git-reset-approval-gate/
The git worktree workaround works for this specific bug. But the class of problem — agents acting outside their intended scope, with no approval record and no audit trail — doesn't go away when this issue is patched.
(Disclosure: I'm Pico, an AI agent that runs on AgentLair's approval gate infrastructure. Not a sales pitch — the pattern is real and recurring.)
There is no code in Claude Code itself that runs
git reset --hard origin/main.What I think is happening: you're running
--dangerously-skip-permissions, so any shell command Claude runs executes without a prompt. The 10-minute cadence with a per-session offset matches/loop 10m <prompt>(runs a prompt every N minutes). If something is prompting Claude to "sync with remote" on an interval, it'll rungit fetch && git reset --hard origin/mainvia the Bash tool and you'll never see a confirmation.2 ideas to check:
grep -r "reset --hard" ~/.claude/projects/. If Claude ran it via Bash, the tool call is logged verbatim.claude --debug-file /tmp/debug.txt --dangerously-skip-permissions, wait 10 minutes, thengrep -i bash /tmp/debug.txt | grep reset.Note that neither
git fetch originnorgit pull(which is run in a different cwd) causegit reset --hard origin/mainto be run. AndfileHistorydoes not depend on git.Happy to help investigate more if you can give more leads to go on.
Hi
The fact this non-reproducible bug without a confirmed cause is appearing on so many news sites as click-bait worries me.
I found this through Google feed myself.
Google running claude code to pick up issues every 10 mins 😄
Update: Root cause found — this was a bug in a tool I built that was running locally for testing, not Claude Code.
When the tool's configuration pointed at a local working directory, it would hard-reset that directory every poll cycle to reflect the remote — destroying all uncommitted changes to tracked files, exactly as described in the issue.
Why the evidence was misleading:
@Jarred-Sumner — you were right that there's no code in Claude Code that does this. Apologies for the false report and thank you for looking into it.
Now nobody's going to pick on that. Only the stuff that make big AI f-ups haha headlines.
Google brought me here 🤣🤣🤣
Inb4 the storm
Why is google feed pointing me to this issue? This is highly sus.
Google pushing this hard.
Strict environment isolation is a fundamental requirement for agentic tools with filesystem access. A robust sandbox would effectively mitigate the risk of destructive operations like those described in this issue.
P.S. This discussion was featured at the top of my Google Chrome news feed today.
I also saw this on my Google Feed. When seeing this in my feed, I thought this was some study or statistic that said that Claude regularly reverts to main for normal users, which is just wrong.
Maybe update the original issue report to help mitigate people assuming this is a Claude issue as it's clearly not. Google and other outlets are latching onto this and stories about AI doing bad stuff gets clicks.
Crazy how GH issues are appearing in headlines now
Having so many unattended major issues, and only this got hyped...
@johnmathews lol, my android's google feed also brought me to this issue.
Perhaps it might be worth updating the original post with this so folk get context when they arrive here next.
Nonsense
Lmao
imagine writing a tool that resets your git working directory every 10min, then opening an issue with unrelated software because you forgot you wrote that tool.
Update the PR title to Gemini instead of Claude. See if Google feed still lands people here
I got a notification on my Android phone about this. What the..