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"

[−] QuantumGood 46d ago
sigh re: - lol ending so many sentences, it's almost replaced
[−] 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.
[−] dragonwriter 47d ago
That's LaTeX convention, double hyphen is an en-dash, triple hyphen is an em-dash.
[−] byronsharman 47d ago
I agree that it should be left as a double hyphen, but an en dash is far more appropriate considering the decades-long precedent set by LaTeX (and continued by Typst).
[−] tom_ 47d ago
Pro tip: pros don't copy and paste from HN titles straight into the command line.

(Or... do they?? Hmm, ok, maybe I need to let this roll around in my mind.)

[−] johnisgood 47d ago
And it should be "--" to begin with, i.e. "--hard".
[−] SoftTalker 47d ago
Two hyphens for an en-dash, three for an em-dash.
[−] rtpg 47d ago
iOS keyboard autocomplete
[−] 0xbadcafebee 47d ago
Article: "Major issue with most popular AI coding tool"

comments: "ThE tItLe iS aI cOded !!!1"

[−] CarVac 47d ago
double hyphens –

triple hyphens —

[−] alcor-z 47d ago
[dead]
[−] mrcwinn 47d ago
Apple actually had the nerve to make it a point to say they’d made their keyboard intelligence better. What a joke. Can’t keyboard, my ass!
[−] 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!