ums: post-merge worktree-tidy pitfalls - #158
Conversation
…verged main Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Working on this — paws off until I'm done. |
This comment has been minimized.
This comment has been minimized.
| **Diverged main checkout:** `git pull --ff-only` fails when the main checkout | ||
| has local commits from a concurrent session that haven't been pushed. Don't | ||
| force-merge or reset their work — skip the pull and delete the branch only. | ||
| The branch deletion is what matters; another session will pull main when it's |
There was a problem hiding this comment.
Gap: after a diverged git pull --ff-only fails, GitHub typically auto-deletes the remote PR branch on merge. The failed pull still ran git fetch, so origin/<pr-branch> may now be gone. With no upstream ref to check, git branch -d <merged-branch> falls back to checking reachability from HEAD (the diverged local main), which doesn't contain the merge commit yet — so it refuses with "not fully merged."
Step 1 already confirms via gh pr view that the PR is merged, so we know it's safe. Suggest noting that if git branch -d refuses here, the verification from step 1 makes it safe to use git branch -D:
| The branch deletion is what matters; another session will pull main when it's | |
| has local commits from a concurrent session that hasn't been pushed. Don't | |
| force-merge or reset their work — skip the pull and delete the branch only. | |
| The branch deletion is what matters; another session will pull main when it's | |
| ready. If `git branch -d` refuses because local `main` doesn't yet include | |
| the merge (diverged HEAD, remote branch already deleted), use `git branch -D` — | |
| step 1 already confirmed the PR is merged, so the force-delete is safe here. |
| ``` | ||
|
|
||
| **Diverged main checkout:** `git pull --ff-only` fails when the main checkout | ||
| has local commits from a concurrent session that haven't been pushed. Don't |
There was a problem hiding this comment.
Minor grammar: "a concurrent session that haven't" should be "hasn't" (the session hasn't pushed, or: "local commits … that haven't been pushed").
| has local commits from a concurrent session that haven't been pushed. Don't | |
| has local commits from a concurrent session that hasn't been pushed. Don't |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ARD Summary — round 1
|
This comment has been minimized.
This comment has been minimized.
|
|
||
| ```bash | ||
| REPO="$(git rev-parse --git-common-dir)/.." # main checkout root | ||
| git -C "$REPO" worktree remove "$(pwd)" # remove this worktree |
There was a problem hiding this comment.
$(pwd) gives the shell's current directory, which may be a subdirectory of the worktree (e.g. worktree/src/). git worktree remove expects the registered worktree root path — a subdirectory path won't match and will error. git rev-parse --show-toplevel always returns the worktree root, regardless of where in the tree the shell is:
| git -C "$REPO" worktree remove "$(pwd)" # remove this worktree | |
| git -C "$REPO" worktree remove "$(git rev-parse --show-toplevel)" # remove this worktree |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ARD Summary — round 2
|
|
Claude finished @d-morrison's task in 2m 10s —— View job Code Review — Round 3
All round-1 and round-2 findings are incorporated correctly. Here's the full verification:
Grammar (line 79): "hasn't" is correct. Round-1 fix applied.
Anti-pattern (line 150): Clean match to the diverged-main prose in step 2. No tension with the existing No hallucinations. No AI-tell clusters. Prose is direct throughout. Verdict: clean. Ready to merge. |
|
Done — PR is clean and free. |
Summary
post-mergestep 2 with two worktree-specific pitfalls hit during PR #141's post-merge:git worktree remove <path>fails when called from inside the worktree being removed — documents thegit -C "$REPO" worktree remove "$(pwd)"fix usinggit rev-parse --git-common-dirgit pull --ff-onlyfails when the main checkout has diverged from a concurrent session's local commits — documents skipping the pull rather than force-merging another session's workTest plan
🤖 Generated with Claude Code