resolve-merge-conflict

現在の branch を分岐元の最新に rebase するときに使う。まず rebase を実行し、止まった conflict を順番に解消して前に進める。長い事前調査を避けて、必要な file だけ見て片付けたいときに使う。

15 stars

Best use case

resolve-merge-conflict is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

現在の branch を分岐元の最新に rebase するときに使う。まず rebase を実行し、止まった conflict を順番に解消して前に進める。長い事前調査を避けて、必要な file だけ見て片付けたいときに使う。

Teams using resolve-merge-conflict should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/resolve-merge-conflict/SKILL.md --create-dirs "https://raw.githubusercontent.com/sushichan044/dotfiles/main/.agents/skills/resolve-merge-conflict/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/resolve-merge-conflict/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How resolve-merge-conflict Compares

Feature / Agentresolve-merge-conflictStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

現在の branch を分岐元の最新に rebase するときに使う。まず rebase を実行し、止まった conflict を順番に解消して前に進める。長い事前調査を避けて、必要な file だけ見て片付けたいときに使う。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# resolve-merge-conflict

## 最初にやること

- branch の目的を 1-2 文で確認する
- rebase 先の branch を決める
- さっさと `git fetch` と `git rebase` を実行する

## 手順

1. 状態確認

   ```bash
   git status --short --branch
   ```

2. base を更新して rebase 開始

   ```bash
   git fetch origin <base>
   git rebase origin/<base>
   ```

3. 止まったら conflict file を確認

   ```bash
   git diff --name-only --diff-filter=U
   ```

4. 簡単な file から解消

- formatter
- import order
- rename / move
- 機械的に両方載せられる変更

1. 迷う file だけ 3-way を見る

   ```bash
   git show :1:path/to/file
   git show :2:path/to/file
   git show :3:path/to/file
   ```

- `:1:` base
- `:2:` applying commit
- `:3:` rebased branch

1. 解消したら追加して続行

   ```bash
   git add <files>
   git rebase --continue
   ```

2. 次の conflict が出たら繰り返す

## squash merge された親ブランチへの rebase

通常の `git rebase` では対処できないケースがある。

**症状**: 親ブランチが squash merge されており、rebase すると親ブランチのコミットが原因のコンフリクトが大量発生する。

**原因**: squash merge は親ブランチの全コミットを 1 つの新しいコミットに畳む。子ブランチの履歴には元の親コミットが残っているため、git は「まだ取り込まれていない」と判断して再適用しようとする。

**対処**:

```bash
# 1. 親 PR の headRefOid(squash 前の先頭コミット)を取得
old_parent_tip=$(gh pr view <親PRの番号> --json headRefOid --jq .headRefOid)

# 2. ローカルに存在するか確認(なければ fetch)
git cat-file -e "$old_parent_tip" 2>/dev/null || \
  git fetch origin $(gh pr view <親PRの番号> --json headRefName --jq .headRefName)

# 3. --onto で「親のコミット以降だけ」を新しい base に乗せ直す
git rebase --onto origin/<新しいbase> "$old_parent_tip"
```

`--onto origin/main <old_parent_tip>` の意味:

- `old_parent_tip..HEAD` の範囲のコミット(= 自分のコミットだけ)を
- `origin/main` の上に乗せる

これで親ブランチのコミットは再適用されない。

## generated file / lockfile

- source file を先に直す
- generated file は後回し
- lockfile は片方を採って前進し、rebase 後に再生成する

例:

```bash
git checkout --ours ui/pnpm-lock.yaml
git add ui/pnpm-lock.yaml
```

## PR を見る条件

最初から見ない。必要なときだけ見る。

- base が曖昧
- branch の目的が commit だけでは読めない
- ユーザー確認前に背景が必要

```bash
gh pr view --json number,title,body,url,baseRefName,headRefName
gh pr diff --name-only
```

## ユーザー確認が必要なケース

- どちらの仕様を採るか決めきれない
- API / UI の最終挙動が二者択一
- config / migration / security 影響がある

確認は短く聞く。

```plaintext
`path/to/file` で conflict しています。
branch 側は <change>、base 側は <change> です。
推奨は <resolution> です。これで進めてよいですか?
```

## 完了後

```bash
git push --force-with-lease origin HEAD
```

push 後、このブランチに open PR があれば `adjust-pr-base` skill を実行する。
rebase 先が変わった場合、PR の base branch も古いまま残ることがあるため。

報告すること:

- どこに rebase したか
- conflict をどう解いたか
- ユーザー確認が必要だった件数

Related Skills

We are still matching the closest adjacent skills for this page. In the meantime, continue through the full directory.