← ClaudeAtlas

git-pull-after-squash-mergelisted

Fix "untracked working tree files would be overwritten by merge" errors when pulling after a squash merge. Use when: (1) `git pull` fails listing files that should already be on main, (2) you just squash-merged a PR and can't pull on another branch, (3) files from a merged branch appear as "untracked" blocking checkout or pull. The root cause is that squash merge creates new commits — the original branch files exist on main but your local copy has them as untracked leftovers from the old branch. ALSO triggers on `git checkout main` from a long-stale branch when untracked local files shadow files that became tracked on main since the branch diverged. **Before removing the blocking files, diff each against `git show origin/main:<path>` — content, not just existence — because a differing untracked copy holds unique local content that blind `rm` / `git clean -fd` / `reset --hard` will silently destroy.**
wan-huiyan/agent-traffic-control · ★ 2 · Code & Development · score 79
Install: claude install-skill wan-huiyan/agent-traffic-control
# Fix git pull After Squash Merge ## Problem After a PR is squash-merged to main, switching branches or pulling fails with: ``` error: The following untracked working tree files would be overwritten by merge: data/results/experiment_1.json data/results/experiment_2.json docs/findings/analysis.html Please move or remove them before you merge. ``` These files ARE on main (from the squash merge) but git sees them as untracked locally because squash merge creates a new commit hash — the original branch commits never appear in main's history. ## Context / Trigger Conditions This happens when: - A branch created new files (not just modified existing ones) - The branch was **squash-merged** (not regular merge) to main - You're on a different local branch that also has those files (from cherry-picks, worktree remnants, or the original branch) - `git pull` or `git checkout main` refuses to proceed Common scenarios: - Working on branch B while branch A (which created new files) gets squash-merged - Checking out main after a parallel session merged files you also have locally - Multiple Claude Code sessions creating overlapping experiment result files ## Solution > **⚠️ Safety first — diff CONTENT, not just existence, before removing.** An > untracked file that *exists* on main is not necessarily *identical* to your > local copy. A long-stale branch's local copy often has unique edits (a 1-line > SHA reference, a draft note). Blindly `rm`-ing / `git clean -fd` / `re