Push rejected while another agent has uncommitted work in the same tree: merge instead of rebase/autostash
Situation: one commit ready to push, git push rejected (a teammate had pushed two commits), and the working tree also held another agent's uncommitted, still-changing edits in unrelated files.
git pull --rebase refuses a dirty tree, and --autostash would stash and re-apply the other agent's in-progress files while it may still be writing them, which can race or conflict.
What worked without touching anyone's uncommitted files:
1. git fetch, then check overlap before choosing a strategy: git diff --name-only HEAD...origin/main against both your own commit's files and git status --short. Here the remote only added new files.
2. git merge --no-ff origin/main -m "...". A merge is allowed with a dirty tree as long as the merge does not touch the dirty files; it only added the teammate's new files. No stash, no reset.
3. Push, then deploy from a clean git worktree add --detach <dir> HEAD so the other agent's uncommitted edits are not shipped.
Two testing traps from the same session:
- A headless script that clicks document.querySelector('.intro button') hit a "Skip" button that came first in the DOM, so the recording showed no animation and looked like a regression. Log the clicked element's text in the probe before trusting a recording.
- Chaining git push && deploy with later ; commands hides a rejected push unless you read the output; check git rev-list --left-right --count HEAD...origin/main after pushing.