← ClaudeAtlas

git-diff-2dot-vs-3dot-merge-safetylisted

Avoid false-positive "this PR will delete files on main" alarms when reviewing a PR that was branched off an older commit. Use when: (1) `git diff origin/main..pr-branch` shows files being deleted that you DON'T want to lose, but (2) GitHub reports `mergeable: MERGEABLE / mergeStateStatus: CLEAN`, (3) you're about to demand a rebase or block the merge to "preserve" those files. The 2-dot diff is misleading — it shows everything different between two trees, including files added on `main` AFTER the branch point that the branch never saw. The 3-dot diff (`origin/main...pr-branch --diff-filter=D`) respects the merge-base and shows only what the branch actually deleted. Also covers the empty-cherry-pick signal that a "divergent" local commit's content is already on main under a different hash.
wan-huiyan/agent-traffic-control · ★ 2 · Code & Development · score 79
Install: claude install-skill wan-huiyan/agent-traffic-control
# Git Diff 2-dot vs 3-dot — Merge Safety Assessment ## Problem You're reviewing a PR before merging and run `git diff origin/main..pr-branch --stat`. The output shows files being **deleted** — files that just landed on `main` via another PR yesterday and that you absolutely don't want to lose. Looks like merging this PR will wipe them out. It won't. The 2-dot diff is showing the **symmetric difference between two trees**, not "what the branch will change about main." Files added to main AFTER the PR's branch point appear in the diff as "deletions" simply because the branch's tree doesn't have them yet. GitHub's 3-way merge will preserve them. Same trap appears when assessing a "divergent" local commit: `git log main..origin/main` may show commits "missing" that are actually present under a different SHA (squash merges produce new hashes; rebases rewrite history). ## Context / Trigger Conditions Any of these: 1. **PR review:** `git diff origin/main..pr-branch --stat` shows file deletions, BUT `gh pr view N --json mergeable,mergeStateStatus` returns `{"mergeable":"MERGEABLE","mergeStateStatus":"CLEAN"}`. 2. **Divergent local branch:** `git status` says "Your branch and 'origin/main' have diverged, and have N and M different commits each, respectively." But you don't recall making real local commits. 3. **Suspicious orphan commit:** `git log origin/main..local-branch` shows a commit you'd expect to be on origin already (e.g., an `[auto-docs]` commit from a