Live data from Hacker News

Claude Code runs Git reset –hard origin/main against project repo every 10 mins

github.com

211–219 of 219 posts

Re: Claude Code runs Git reset –hard origin/main against project repo every 10 mins

#211
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.

Re: Claude Code runs Git reset –hard origin/main against project repo every 10 mins

#213

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 describe…

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"

Re: Claude Code runs Git reset –hard origin/main against project repo every 10 mins

#214
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.

Re: Claude Code runs Git reset –hard origin/main against project repo every 10 mins

#215

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 describe…

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"

sigh re: - lol ending so many sentences, it's almost replaced

Re: Claude Code runs Git reset –hard origin/main against project repo every 10 mins

#216
post #209

Earlier quoted context omitted.

Probably something innocuous like “Sync with the server periodically to get the latest” Tracks for what we can infer

This is the part where you'd normally pull the junior engineer aside and politely give them a stern talking to until they understood what they did wrong. If anybody has suggestions for how to do this with LLMs (short of maintaining CLAUDE_wall_of_shame.md), please share. Edit: for the record, yes I do run a linter, and generally try not to impose bikeshedding or soapboxes on my peers. It's just that there are certain…

What I do to avoid this is to manually approve each change Claude is doing

I think the yolo mode of auto approve changes is to the root cause, which is probably a little embarrassing to be that engineer we’re all collectively pulling aside to ask:

Is this the result of automatically letting the robot tune your machine?

Re: Claude Code runs Git reset –hard origin/main against project repo every 10 mins

#217
post #108

Earlier quoted context omitted.

Why do you expect that a weighted random text generator will ever behave in predictable way? How can people be so naive as to run something like Claude anywhere other than in a strictly locked down sandbox that has no access to anything but the single git repo they are working on (and certainly no creds to push code)? This is absolutely insane behavior that you would give Claude access to your GitHub creds. What happ…

> How can people be so naive as to run something like Claude anywhere other than in a strictly locked down sandbox that has no access to anything but the single git repo they are working on (and certainly no creds to push code)? Because it’s insanely useful when you give it access, that’s why. They can do way more tasks than just write code. They can make changes to the system, setup and configure routers and network…

Well, one of the other reasons I suggest running it in a strictly limited container is that you can then run it in yolo mode.

In fact, I use the pi agent, which doesn't have command sandboxing, it's always in yolo mode, I just run it in a container and then I get the benefit of not having to confirm every command, while strictly controlling what I share with it from the beginning of the session.

Re: Claude Code runs Git reset –hard origin/main against project repo every 10 mins

#218
post #64

Earlier quoted context omitted.

It's not a one off issue - it has happened to me a few times. It has once even force pushed to github, which doesn't allow branch protection for private personal projects. Here's an example. 1) claude will stash (despite clear instructions never to do so). 2) claude will use sed to bulk replace (despite clear instructions never to do so). sed replacements make a mess and replaces far too many files. 3) claude restore…

When will you all learn that merely "telling" an LLM not to do something won't deterministically prevent it from doing that thing? If you truly want it to never use those commands, you better be prepared to sandbox it to the point where it is completely unable to do the things you're trying to stop.

[flagged]
Post reply on HN