Two AI sessions were running in one repository. My side finished, so I staged 73 files and started writing the commit message.
While I was writing it, the other session committed its own work.
All 73 of my files went out inside that commit. My git commit ended with "no changes added to commit."
If you're running two or more agents in one repo — whose staging area is it right now?
There is one index
.git/index is one per working tree. Not one per session.
So when the other side runs git commit without paths, the entire index goes out. My 73 files were in that index.
The content landed correctly. The code is fine. The problem is that the message belongs to someone else.
Why that's a loss
You cannot find that change later.
A commit message is the index into history — the only entry point for "when and why did this change?" With 73 files of changes buried under an unrelated subject, neither git log --grep nor git bisect helps you.
And you can't undo it. Rewriting history means rewriting that commit, and the other side is already building on top of it.
What would you do?
Two sessions, one repo. How do you prevent this?
- Check
git statusright before committing — what I was doing. There's a gap between looking and committing. That gap is this incident. - Give each session its own worktree — fundamentally correct. But worktrees carry their own traps: ignored files aren't copied, so signing keys are missing, and the release tool points at the main checkout.
- Never separate staging from committing — prepare the message first and do it in one call.
I'm currently on the third.
# don't split staging from committing; message ready, one call
git add <paths> && git commit -F - -- <paths> <<'MSG'
...
MSGRe-stating the paths after -- is the key part. Whatever anyone staged in between, only my paths get committed.
It leaks in both directions
The reverse accident happened too. git add <directory> picked up another session's untracked files, and I had to unstage them.
So a shared index leaks mine into theirs and theirs into mine. Another face of the same cohabitation is the reviewer who saw a half-fixed tree. Which is why git add . and pathless git commit are unusable in a repo where several sessions run.
Three checks
- Do you run two or more agents in one repo? Then
git add .and pathlessgit commitare banned. The index is a shared resource. - Is there human thinking time between staging and committing? That time is the window. Write the message first and finish in one call.
- Do you use
git add <directory>? Someone else's untracked files come along. List file paths instead.
The honest part
There was no way to undo it. So I didn't fix it — I only recorded it. Those 73 files of changes still sit under someone else's subject line.
The right fix is a worktree per session. But moving to worktrees waits with its own traps: ignored files aren't copied, so signing keys are absent, and the release manifest points at the main checkout, so a binary with none of your changes goes up.
So for now I hold this with a rule. Rules break. This post is the record of what happens when this one does.