Loading...
Loading...
Use when merging a branch to main without touching the primary worktree directly, when /ship or /reflect needs to integrate work, or when autonomous mode blocks direct main commits
npx skill4agent add camacho/ai-skills local-merge| Input | Required | Default | Example |
|---|---|---|---|
| yes | — | |
| no | | |
| no | First line of | |
| no | | |
git fetch origin "$TARGET" "$BRANCH"
DEPTH=$(( $(git rev-list --count origin/"$TARGET"..origin/"$BRANCH") + 10 ))MERGE_DIR="${CLAUDE_SESSION_DIR:-/tmp}/local-merge-$$"
[ -d "$MERGE_DIR" ] && rm -rf "$MERGE_DIR"
git clone --depth "$DEPTH" --branch "$TARGET" "$(git remote get-url origin)" "$MERGE_DIR"
git -C "$MERGE_DIR" fetch origin "$BRANCH"
git -C "$MERGE_DIR" merge FETCH_HEAD -m "$MESSAGE"
git -C "$MERGE_DIR" pushgit -C "$MERGE_DIR" pull --rebase
git -C "$MERGE_DIR" pushrm -rf "$MERGE_DIR"$TARGETgit -C "$PRIMARY" branch --show-current$TARGET<branch>$TARGETgit -C "$PRIMARY" status --porcelaingit -C "$PRIMARY" add -A
git -C "$PRIMARY" commit -m "wip: preserve local state before remote sync"WIP_CREATED=truegit -C "$PRIMARY" fetch origin "$TARGET"git -C "$PRIMARY" rev-list --count HEAD..origin/"$TARGET" # commits behind
git -C "$PRIMARY" rev-list --count origin/"$TARGET"..HEAD # commits ahead
git -C "$PRIMARY" diff HEAD..origin/"$TARGET" --stat # changed files
git -C "$PRIMARY" log HEAD..origin/"$TARGET" --oneline # incoming commits
git -C "$PRIMARY" log origin/"$TARGET"..HEAD --oneline # local-only commits| Behind | Ahead | Assessment | Action |
|---|---|---|---|
| N > 0 | 0 | Fast-forward | |
| N > 0 | M > 0 | Diverged | Inspect diff for file overlap + semantic risk (2e) |
| 0 | 0 | Already current | Skip, report, done |
| 0 | M > 0 | Local-only commits | Unexpected — escalate to copilot (2f) |
git -C "$PRIMARY" merge --ff-only origin/"$TARGET"git -C "$PRIMARY" merge origin/"$TARGET" --no-editgit -C "$PRIMARY" merge --abort/copilot/autonomousWIP_CREATED=truegit -C "$PRIMARY" reset --soft HEAD~1pull --rebase--forcemerge --abort| Caller | Context |
|---|---|
| CI-down path after review approval |
| Post-task consolidation to main |
| Receives escalation from Phase 2f |
| Restored after copilot resolves conflict |