2.7 KiB
2.7 KiB
name, description
| name | description |
|---|---|
| land-merged-pr-with-blocked-tree-ops | Use when a merged PR must land in a checkout whose working tree is dirty and workspace policy blocks git switch/restore/stash/reset-to-commit: prove identity, commit forward, merge, verify. |
Landing a merged PR into a checkout with blocked tree operations
Shared-workspace policy can block git switch, git checkout <branch>, git restore, git stash, and git reset <commit> ("uncommitted changes other concurrent agents rely on"). A git pull --ff-only then aborts with "Your local changes to the following files would be overwritten by merge" — even when the local content is byte-identical to the incoming commit, because git compares the index, not intent. Observed twice on 2026-10-19 (dank/command-center, dank/dankvoice).
Procedure
- Prove identity first — never assume it.
git fetch && git diff --stat origin/main -- <the dirty paths>→ empty output means the working tree already equals the merged result, so committing it forward destroys nothing. If it is not empty, stop: there is real local work; do not proceed. - Commit forward the identical paths (message says exactly that, e.g. "land merged #N content; policy blocks restore/stash, so the identical copies are committed rather than discarded"). Hooks still run.
- Merge, don't ff:
git merge --no-edit origin/main(ort resolves identical changes on both sides cleanly).--ff-onlyis impossible once step 2 created a commit. - Untracked-collision case: if the abort says "Please move or remove them before you merge", an untracked local file occupies a path the merge adds.
mvit aside, merge, thencmpthe restored file against the copy — identical → drop the copy (if the copy came from.AGENTTRASH, delete it andrmdir, since the file is now tracked). - Verify: repo lint/tests,
git status --porcelain -- <paths>empty, andgit rev-parse --short HEAD origin/mainequal after a freshgit fetch.
Gotchas
git merge … | tail -3masks the exit status —tailalways exits 0 and an&&chain then continues past an aborted merge. Run the merge unmasked, or check${PIPESTATUS[0]}.- Immediately after a push,
git rev-list --count main..origin/maincan report phantom commits-behind from a stale remote-tracking snapshot. Re-fetchand comparerev-parsebefore believing any drift. - Do not push redundant commits into a deployment checkout without checking the repo's tier law: machine/live tiers commit straight to
main, human/agent prose goes by PR.
Never
No --no-verify, no reset --hard, no checkout -- <path>, no "temporary" stash: those are exactly the operations the policy blocks because they discard other agents' work.