Claude Code runs Git reset –hard origin/main against project repo every 10 mins (github.com)

by mthwsjc_ 191 comments 251 points
Read article View on HN

191 comments

[−] ZeljkoS 47d ago
Update from the author: https://github.com/anthropics/claude-code/issues/40710#issue...

"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."

[−] progbits 46d ago
So much "thorough investigation" done but the author did not consider turning off claude for 10 minutes to see if the problems stops? lol

Flagged the submission as it's inaccurate. Will unflag if title gets changed to something like "dev builds script that resets their git repo every 10 minutes, forgets about it, blames claude code with no evidence"

[−] kibwen 47d ago
Let's focus on the real issue here, which is that HN has apparently normalized the double hyphen in the title to an en dash--yes, an en dash, not even an em dash.
[−] Jarred 47d ago
I spent some time investigating this, and the issue is not accurate - Claude Code itself does not have code that spawns git reset --hard origin/main

Most likely, the developer ran /loop 10m or asked claude to create a cron task that runs every 10 minutes and refreshes & resets git.

[−] kccqzy 47d ago

> Process monitoring at 0.1-second intervals found zero git processes around reset times.

I don’t think this is a valid way of checking for spawned processes. Git commands are fast. 0.1-second intervals are not enough. I would replace the git on the $PATH by a wrapper that logs all operations and then execs the real git.

[−] simianwords 47d ago
I think this post potentially mischaracterises what may be a one off issue for a certain person as if it were a broader problem. I'm guessing some context has been corrupted?
[−] luxurytent 47d ago
Not sure I understand, wouldn't permissions prevent this? The user runs with --dangerously-skip-permissions so they can expect wild behaviour. They should run with permissions and a ruleset.
[−] lambda 47d ago
Who would have guessed that running a binary blob dev tool, that is tied to a SaaS product, which was mostly vibe-coded, could lead to mysterious, hard to debug problems?
[−] thunfischtoast 47d ago
From the issue author:

> Update: Root cause found — this was a bug in a tool I built that was running locally for testing, not Claude Code.

[−] mememememememo 47d ago
As a side note. Always configure remote to reject any kind of trunk push. And ideally any forced push on branches.
[−] byearthithatius 47d ago
Regardless of if this is common its getting popular because its objectively hilarious and we can all see it being possible.
[−] nstj 47d ago
As an FYI you can recover from force pushes to GitHub using their UI[0] or their API[1].

And if you force push to one of your own machines you can use the reflog[2].

[0]: https://stackoverflow.com/a/78872853 [1]: https://stackoverflow.com/a/48110879 [2]: https://stackoverflow.com/a/24236065

[−] bastard_op 46d ago
I have a similar issue, where normally I use claude-code in an srt or bwrap direct sandbox, but when I don't, claude-code will call gh _every_ time I backspace out of a /command or escape a menu such a /mcp, any time I paste something, as well as on some timer that sounds like the issue owner's complaint of 10 minutes.

I know because I use keepassxc as my secret provider, so I get an approval prompt to allow or deny it _every_time_, so I darn well notice it as it'll grab focus when typing something. Inside a sandbox it tries but without access to creds or env, it just silently fails, so I never noticed while in-sandbox, just when out-of-sandbox, which I do occasionally to let it do some sysadmin/housecleaning task for me.

I finally asked Claude why: "Root cause: It's Claude Code's built-in git context feature, not hooks.

So unless you keep your secrets open to the user regardless who's asking for them, it'll nag you to escape out of menus with a gh query. KeepassXC doesn't let you set a per-session limit, it's either right now for forever.

[−] oelmgren 47d ago
I'm curious how common this is or if this just affects this one user.
[−] agent_anuj 47d ago
I give you my personal experinces. I use it for everything design, coding, testing, deploying to kubernetes cluster, fixing issues on cluster. I use it to fix not only dev env issues, I use it for production issues. Confidently. Have things gone wrong. Sure. But mistakes have been rare (and catastrophic mistake - non recoverable , even rarer).

Everytime a mistake has happened,on diggin in I was always trace it back to something which I did wrong - either being careless in reading what it told me , or careless in telling what I want. I have had git code corruption issues, it overwrote uncommited working code with non working code. But it was my mistake to not tell it to commit the code before makign changes. It deleted QA cluster database but becuase I told it to delete it thinking it was my dev setup db. Net net. It;s mistakes are more a reflection of me as its supervisor than anything else.

[−] jrvarela56 47d ago
It’s a feature not a bug!
[−] mrothroc 46d ago
I see this has been updated by the user showing it is their own tool doing the damage.

These things happen. They happened before coding agents, they happen now. I've done plenty of damage with my own ten fingers on the keyboard without any help from an LLM.

This is exactly why I develop on a Mac with Time Machine. It has saved my bacon many times. Both from things I did and from things Claude did. I've had several recent incidents that went like this:

"me: Claude, did you delete X?" "claude: Yes, sorry, I shouldn't have done that. I can reconstruct it." [Narrator: no, claude cannot reconstruct it.] "me: Should I just restore it from Time Machine?" "claude: Yes! That's perfect!"

I swear I can feel a sense of relief from Claude when I tell it I can just restore from backup.

[−] ghelmer 47d ago
That is not my experience.
[−] 1123581321 47d ago
This looks similar to a bug report Claude Code offered to file for me after it became confused about my shell environment. The author is probably running something (maybe /loop as suggested in the comment.) In my case, a restart fixed the envs.
[−] newfriend 47d ago

>Update: Root cause found — this was a bug in a tool I built that was running locally for testing, not Claude Code.

[−] whateveracct 47d ago
that must be a very powerful claude.md
[−] bicepjai 46d ago
If we are living in an era where software release everyday is the norm, no amount of testing is enough to claim stability. Roll the dice everyday with these beautiful stochastic imitators.
[−] nerolawa 47d ago
Highly recommend to deny commands in user settings.json like git reset
[−] mmaunder 47d ago
Can we immunize HN against being yet another AI drama site? Obviously this isn’t a fundamental issue with agents or AI or Anthropic but a misconfiguration edge case.
[−] chaos_emergent 47d ago
Have you considered that Claude set up a crontab that does that programmatically? Every 10 mins seems awfully, idk, regular.
[−] jxcole 47d ago
The obvious solution is to just copy paste it into Claude itself and ask it to fix. Works for almost any Claude problem
[−] rkrbaccord94f 47d ago
95+ entries that are logged at 10 min intervals

/10 * * * /usr/ schedules script execution

[−] simonw 47d ago
Has anyone been able to replicate the behavior described in this issue yet?
[−] meander_water 47d ago
Probably does it to reduce context for regex/git history searches
[−] meltyness 47d ago
is this token friendly?
[−] TZubiri 47d ago
tbf, that's claude's workspace

do not share a workspace with the llm, or with anybody for that matter.

How would the llm even distinguish what was wrote by them and what was written by you ?

[−] simianwords 47d ago
Prompt injection?
[−] lqstuart 47d ago
if an idea can't be vibecoded in under 10 minutes, it's not worth pursuing. Checks out
[−] dboreham 47d ago
But it doesn't.
[−] gverrilla 47d ago
obviously a user mistake, not a claude code bug
[−] irishcoffee 47d ago
I’m having this weird vision of a “the matrix 3” type machine crawling around inside Microsoft’s GitHub servers central repository and just wreaking havoc.

This whole LLM thing is a blast, huh?

[−] nickphx 47d ago
cool. if you choose to use a non-deterministic black box of bullshit, should you really be surprised when it shits all over your floor?
[−] anvevoice 47d ago
[dead]
[−] royschwartz 47d ago
[dead]
[−] imta71770 47d ago
[flagged]
[−] getverdict 47d ago
[dead]
[−] MeetRickAI 47d ago
[flagged]
[−] wazionapps 46d ago
[flagged]
[−] minsung0830 47d ago
[flagged]
[−] ryguz 47d ago
[dead]
[−] kaluga 45d ago
[dead]
[−] winna 47d ago
[dead]