jpskill.com
🛠️ 開発・MCP コミュニティ 🔴 エンジニア向け 👤 エンジニア・AI開発者

🛠️ Git Rebase Sync

git-rebase-sync

自分が担当している機能開発の作業を、

⏱ テスト計画作成 2時間 → 20分

📺 まず動画で見る(YouTube)

▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗

※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。

📜 元の英語説明(参考)

Use when syncing a feature branch onto the latest origin base branch via git rebase.

🇯🇵 日本人クリエイター向け解説

一言でいうと

自分が担当している機能開発の作業を、

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o git-rebase-sync.zip https://jpskill.com/download/4027.zip && unzip -o git-rebase-sync.zip && rm git-rebase-sync.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/4027.zip -OutFile "$d\git-rebase-sync.zip"; Expand-Archive "$d\git-rebase-sync.zip" -DestinationPath $d -Force; ri "$d\git-rebase-sync.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して git-rebase-sync.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → git-rebase-sync フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-18
同梱ファイル
1

💬 こう話しかけるだけ — サンプルプロンプト

  • Git Rebase Sync を使って、最小構成のサンプルコードを示して
  • Git Rebase Sync の主な使い方と注意点を教えて
  • Git Rebase Sync を既存プロジェクトに組み込む方法を教えて

これをClaude Code に貼るだけで、このSkillが自動発動します。

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

[スキル名] git-rebase-sync

git-rebase-sync

このスキルは、git rebase を使用してフィーチャーブランチを最新の origin/{base_branch} に同期する必要がある場合に使用します。これには、意図が不明確な場合の明確な確認質問を伴う競合解決も含まれます。

目標

  • 現在のブランチを指定されたベースブランチ(多くの場合、devmain のようなリポジトリのデフォルトブランチ)にリベースします。
  • 推測に頼らず、意図的に競合を解決します。
  • 安全策を講じます:バックアップリファレンス、履歴を書き換えるコマンドの前の確認、安全なプッシュ。

厳守事項

  • 別のフィーチャーブランチを作成したり、切り替えたりしないでください。私が明示的に指示しない限り、現在のブランチ名で操作してください。
  • 履歴を書き換えるコマンド(git rebase ...git push --force*)を実行する前に、実行する正確なコマンドを表示し、私の確認を待ってください。
  • リベースを開始する前に、ローカルのバックアップリファレンス(注釈付きタグを推奨)を作成してください。私が明示的に指示しない限り、バックアップリファレンスをプッシュしないでください。
  • git push --force-with-lease を優先し、決して単なる --force を使用しないでください。
  • 正しい競合解決が不明確な場合は、停止して的を絞った質問をしてください。製品の動作をでっち上げないでください。

ワークフロー

1) ベースブランチと現在のブランチの特定

  • 現在のブランチを特定します:
    • git branch --show-current
  • リベースするベースブランチを特定します:
    • 指定されていない場合は、GitHub のデフォルトブランチを使用します:
      • gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'
  • 最新の情報をフェッチします:
    • git fetch origin

2) 飛行前安全チェック

  • ワーキングツリーがクリーンであり、進行中の操作がないことを確認します:
    • git status
  • git status が進行中のマージ/リベース/チェリーピックを示している場合は、停止してどうするか(中止するか続行するか)を尋ねてください。

3) ローカルバックアップリファレンスの作成(プッシュしない)

  • 現在の HEAD に注釈付きタグを作成します:
    • git tag -a {branch_name}-rebase-backup-$(date +%Y%m%d-%H%M%S) -m "pre-rebase backup" HEAD
  • リカバリのためにタグ名を {backup_ref} として記録します。

4) リベースモードの選択(通常 vs マージを保持)

  • ブランチにマージコミットが含まれているか確認します:
    • git rev-list --count --merges origin/{base_branch}..HEAD
  • マージコミットが存在する場合は、それらを保持するか(--rebase-merges)、それとも平坦化するか(プレーンリベース)を尋ねてください。

5) リベースの実行(確認が必要)

  • 実行しようとしている正確なコマンドを表示し、確認を待ちます:
    • 通常:
      • git rebase origin/{base_branch}
    • マージ保持あり:
      • git rebase --rebase-merges origin/{base_branch}

6) 競合処理ループ

競合が発生した場合:

  1. コンテキストを収集します:
    • git status
    • 競合しているファイルを特定します(ステータス出力から)。
  2. 競合しているファイルごとに:
    • ファイルを開き、周囲のコードと意図を理解します。
    • 最小限の機械的な競合解決を優先します:
      • フィーチャーブランチが意図的に上書きしない限り、アップストリームの変更を保持します。
      • 適切な場合は、手動で編集する代わりにジェネレーター(ロックファイル、コード生成)を再実行します。
    • 意図が不明確な場合は、的を絞った単一の質問をしてください。例えば:
      • 「新しいアップストリームの動作 X を保持すべきですか、それともフィーチャーの動作 Y を保持すべきですか?」
      • 「このファイルは生成されたもので、安全に再生成できますか、それとも手動で解決したいですか?」
  3. 解決を適用し、解決済みのファイルのみをステージングします:
    • git add <file...>
  4. 続行します:
    • git rebase --continue
  5. 解決が危険すぎる、または不明確な点に達した場合:
    • 停止して尋ねてください。オプションでリベースの中止を提案してください。

競合中の便利なコマンド:

  • 現在の競合チャンクを検査する:git diff
  • リプレイされているコミットを見る:git show
  • 元に戻す必要がある場合:git rebase --abort(これは安全であり、破壊的なリセットよりも推奨されます)

7) リベース後の検証

  • 新しいコミット範囲を表示します:
    • git log --oneline --decorate origin/{base_branch}..HEAD
  • 利用可能な場合は、適切なリポジトリチェック(テスト、型チェック、リンター)を実行します。

8) 更新されたブランチのプッシュ(確認が必要)

  • ブランチがすでに origin に存在する場合、リベースは履歴を書き換えるため、プッシュには force-with-lease が必要です。
  • 正確なコマンドを表示し、確認を待ちます:
    • git push --force-with-lease origin HEAD:{branch_name}

リカバリ

  • 何か問題が発生した場合は、{backup_ref} を使用してリベース前の状態を復元してください。
  • 破壊的なコマンド(例:git reset --hard)は、私が正確なコマンドを表示した後に明示的に確認しない限り、実行しないでください。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

git-rebase-sync

Use this skill when you need to sync a feature branch onto the latest origin/{base_branch} via git rebase, including conflict resolution with explicit clarification questions when intent is ambiguous.

Goals

  • Rebase the current branch onto a specified base branch (often the repo default branch like dev or main).
  • Resolve conflicts deliberately, without guesswork.
  • Keep safety rails: backup ref, confirmations before history-rewriting commands, and safe pushing.

Hard Rules

  • Do not create or switch to a different feature branch. Operate on the current branch name unless I explicitly ask otherwise.
  • Before any history-rewriting command (git rebase ..., git push --force*), print the exact command(s) you will run and wait for my confirmation.
  • Create a local backup ref (prefer an annotated tag) before starting the rebase. Do not push backup refs unless I explicitly ask.
  • Prefer git push --force-with-lease, never plain --force.
  • If the correct conflict resolution is unclear, stop and ask a targeted question. Do not invent product behavior.

Workflow

1) Identify base + branch

  • Determine the current branch:
    • git branch --show-current
  • Determine the base branch you will rebase onto:
    • If not provided, use GitHub default branch:
      • gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'
  • Fetch latest:
    • git fetch origin

2) Preflight safety checks

  • Ensure the working tree is clean and there is no operation in progress:
    • git status
  • If git status indicates an in-progress merge/rebase/cherry-pick, stop and ask what to do (abort vs continue).

3) Create a local backup ref (do not push)

  • Create an annotated tag at current HEAD:
    • git tag -a {branch_name}-rebase-backup-$(date +%Y%m%d-%H%M%S) -m "pre-rebase backup" HEAD
  • Record the tag name as {backup_ref} for recovery.

4) Choose rebase mode (normal vs preserve merges)

  • Check whether the branch contains merge commits:
    • git rev-list --count --merges origin/{base_branch}..HEAD
  • If merge commits exist, ask whether to preserve them (--rebase-merges) or flatten them (plain rebase).

5) Run the rebase (requires confirmation)

  • Print the exact command you intend to run, then wait for confirmation:
    • Typical:
      • git rebase origin/{base_branch}
    • With merge preservation:
      • git rebase --rebase-merges origin/{base_branch}

6) Conflict handling loop

When conflicts happen:

  1. Collect context:
    • git status
    • Identify conflicted files (from status output).
  2. For each conflicted file:
    • Open the file and understand the surrounding code and intent.
    • Prefer minimal, mechanical conflict resolutions:
      • Keep upstream changes unless the feature branch deliberately supersedes them.
      • Re-run generators (lockfiles, codegen) instead of hand-editing when appropriate.
    • If intent is ambiguous, ask a single targeted question, for example:
      • "Should we keep the new upstream behavior X, or keep the feature behavior Y?"
      • "Is this file generated and safe to regenerate, or do you want manual resolution?"
  3. Apply the resolution, then stage only resolved files:
    • git add <file...>
  4. Continue:
    • git rebase --continue
  5. If you reach a point where resolution is too risky/unclear:
    • Stop and ask; optionally propose aborting the rebase.

Helpful commands during conflicts:

  • Inspect current conflict hunks: git diff
  • See the commit being replayed: git show
  • If you need to back out: git rebase --abort (this is safe and should be preferred over destructive resets)

7) Post-rebase verification

  • Show the new commit range:
    • git log --oneline --decorate origin/{base_branch}..HEAD
  • Run appropriate repo checks (tests, typecheck, lint) if available.

8) Push updated branch (requires confirmation)

  • If the branch already exists on origin, rebasing rewrites history, so pushing requires force-with-lease.
  • Print the exact command and wait for confirmation:
    • git push --force-with-lease origin HEAD:{branch_name}

Recovery

  • If something goes wrong, use {backup_ref} to restore the pre-rebase state.
  • Do not run destructive commands (e.g., git reset --hard) unless I explicitly confirm after you show the exact command.