mergemainlisted
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 `<<<<<<<`