Today while i’ve been working, I noticed that there were about 25 files that I had staged that had become unstaged. There were some files that were left in staged. I’m not sure how this happened and when I asked the agent to check it wasn’t very helpful.
went through and re-staged all the ones that were unstaged. Some time later as the agent continued to make changes to other files I noticed the same thing had happened again so I have 40 unstaged files that I have to check again.
This is quite frustrating, is there any workaround for now and is this a known issue?
Hey, thanks for the report. Good news: the files weren’t lost. They just went back to unstaged, and you can stage them again.
Cursor itself doesn’t unstage files in the editor on its own, so the most likely cause is a git command the agent ran in the terminal. git stash followed by git stash pop can do this. Agents sometimes use that to check whether a test was already broken before their changes. It returns modified files as unstaged, but keeps newly added files staged. That matches exactly what you described. git reset or git restore --staged would cause the same effect too.
Could you scroll through the agent chat and check whether it ran git stash, git reset, git restore, or git checkout around the time this happened? Running git reflog in the repo should also show any reset. If you send what you find, that’d really help us figure it out.
For now, a few things should help stop this from happening again:
Open Cursor Settings > Agents > Execution and Approvals and set Run Mode to “Ask Every Time” or remove the broad git allowlist entry, so you can see every git command before it runs.
Add a User Rule in Cursor Settings > Rules, for example: “Never run git stash, git reset, git restore, git checkout, or any other command that changes the git index or working tree unless I explicitly ask.”
Commit work in progress instead of keeping it only in the staging area while the agent is working.
Let us know what you find in the chat or in git reflog.