fix: clean untracked .gsd/ files before squash-merge to prevent failure (#1239)

syncStateToProjectRoot copies .gsd/ files to the project root during
worktree execution. When .gsd/ is gitignored, these remain untracked.
Git refuses squash-merge because 'untracked working tree files would
be overwritten by merge.'

Added git clean -fd .gsd/ after autoCommitDirtyState and before the
branch checkout/merge sequence. This removes the untracked copies
without affecting tracked files.

Fixes #1237
This commit is contained in:
Tom Boucher 2026-03-18 15:54:06 -04:00 committed by GitHub
parent 8ac58d88f0
commit 8c1f98bc3f

View file

@ -540,6 +540,15 @@ export function mergeMilestoneToMain(
// "Your local changes to the following files would be overwritten by merge" (#1127).
autoCommitDirtyState(originalBasePath_);
// 3b. Remove untracked .gsd/ files that syncStateToProjectRoot copied.
// autoCommitDirtyState stages and commits everything (git add -A), but if
// the project root branch has no .gsd/ tracking (e.g., .gsd/ is gitignored),
// these files remain untracked and cause "untracked working tree files would
// be overwritten by merge" during squash-merge (#1237).
try {
execFileSync("git", ["clean", "-fd", ".gsd/"], { cwd: originalBasePath_, stdio: "pipe" });
} catch { /* non-fatal — clean failure shouldn't block merge attempt */ }
// 4. Resolve integration branch — prefer milestone metadata, fall back to preferences / "main"
const prefs = loadEffectiveGSDPreferences()?.preferences?.git ?? {};
const integrationBranch = readIntegrationBranch(originalBasePath_, milestoneId);