smithery.ai

rebase-workflow

rebase を用いてリモートのデフォルトブランチの変更を作業ブランチに取り込む。「リモート変更を取り込む」「rebase」「master/main を同期」「ブランチを最新にする」依頼で使う

First seen Mar 21, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 3,360 B
  • docs SUMMARY.md 129 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1 installs

SKILL.md

Rebase Workflow

リモートのデフォルトブランチの変更を、rebase を使って安全に作業ブランチに取り込む手順です。

前提条件

  • 作業ブランチで作業中であること(デフォルトブランチではないこと)
  • コミットしていない変更がないこと(git status で確認)

手順

1. リモート状態の更新とデフォルトブランチ名の取得

デフォルトブランチ名はリポジトリによって異なります(master, main, develop など)。ローカルの origin/HEAD はリモート側のデフォルトブランチ変更に自動追従せず、古い値を正常終了で返しうるため、参照する前に次の 2 コマンドを順に実行してリモート状態を更新します:

git fetch --prune origin
git remote set-head origin --auto

そのうえでデフォルトブランチ名を取得します:

git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'

2. rebase で変更を取り込む

git rebase origin/<default-branch>

例(デフォルトブランチが master の場合):

git rebase origin/master

3. コンフリクト発生時の対処

rebase 中にコンフリクトが発生した場合:

  1. 状況確認

``bash git status `` コンフリクトしているファイルが表示されます。

  1. コンフリクトを解決

- 各ファイルを開き、<<<<<<<, =======, >>>>>>> マーカーを探す - 適切な内容に修正 - 修正後、ステージに追加: ``bash git add <file> ``

  1. rebase を継続

``bash git rebase --continue ``

  1. rebase を中止する場合(元の状態に戻す)

``bash git rebase --abort ``

4. リモートへの push

rebase 後は履歴が書き換わるため、通常の git push は失敗します。 --force-with-lease を使って安全に push します:

git push --force-with-lease

注意: --force-with-lease は、他の誰かがリモートブランチに push した場合に失敗します。
これにより、他人の変更を誤って上書きすることを防げます。
単なる --force は絶対に使用しないでください。

トラブルシューティング

デフォルトブランチ名が取得できない

手順 1 の 2 コマンド (fetch --prune / set-head --auto) を実行済みでも取得できない場合は、リモートとの接続と HEAD branch を確認してください:

git remote show origin

rebase 中に大量のコンフリクトが発生

小さな単位で rebase を行うか、git rebase --abort で中止してマージを検討してください。

push が拒否された

--force-with-lease が失敗する場合、他の誰かがリモートブランチを更新しています。 再度 git fetch して状況を確認してください。