← ClaudeAtlas

mergemainlisted

Safely bring the latest main into the current branch. Fetches main fresh from the remote, merges it into the working branch, and resolves conflicts by reading the full context of both sides — keeping the branch's logic changes and main's unrelated UI/infra changes rather than blindly taking one side. Asks the user whenever intent is genuinely ambiguous. Use when asked to merge or sync with main, update a branch, or when the user runs /mergemain.
nazmulnahid-git/Ai-Stack · ★ 2 · Code & Development · score 73
Install: claude install-skill nazmulnahid-git/Ai-Stack
# mergemain Merge the latest `main` into the current branch and resolve the conflicts correctly. The whole point is the conflict resolution: **never** resolve by picking a side because it is easier. ## Step 1 — Pre-flight ``` git rev-parse --abbrev-ref HEAD # current branch git status --porcelain # must be clean git remote -v git rev-parse --abbrev-ref origin/HEAD # real default branch (main/master/develop) ``` - If HEAD is already the default branch, stop and tell the user — there is nothing to merge. - If the working tree is dirty, stop and ask: commit, stash, or abort. Do not stash silently; someone's uncommitted work is not yours to move. - Note the current HEAD sha so you can offer an exact rollback later. ## Step 2 — Get main fresh ``` git fetch origin --prune ``` Merge from `origin/<default>` directly — do not check out main, and do not rely on a stale local copy. Report how far behind the branch was (`git rev-list --count HEAD..origin/main`) and how many files main touched. ## Step 3 — Merge ``` git merge origin/main --no-edit ``` If it merges cleanly, jump to Step 6. ## Step 4 — Understand before resolving List the conflicts (`git diff --name-only --diff-filter=U`) and, for each file, build real context before touching it: - `git log --oneline HEAD..origin/main -- <file>` — why main changed it. - `git log --oneline origin/main..HEAD -- <file>` — why this branch changed it. - Read the **whole file**, not just the `<<<<<<<`