/git-guardrails:rebase-workflowfrom git-guardrails
rebase を用いてリモートのデフォルトブランチの変更を作業ブランチに取り込む。「リモート変更を取り込む」「rebase」「master/main を同期」「ブランチを最新にする」依頼で使う
Ships in git-guardrails. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
リモートのデフォルトブランチの変更を、rebase を使って安全に作業ブランチに取り込む手順です。
git status で確認)デフォルトブランチ名はリポジトリによって異なります(master, main, develop など)。ローカルの origin/HEAD はリモート側のデフォルトブランチ変更に自動追従せず、古い値を正常終了で返しうるため、参照する前に次の 2 コマンドを順に実行してリモート状態を更新します:
git fetch --prune origin
git remote set-head origin --auto
そのうえでデフォルトブランチ名を取得します:
git symbolic-ref refs/remotes/origin/HEAD
出力 refs/remotes/origin/<name> の <name> 部分がデフォルトブランチ名です (prefix の refs/remotes/origin/ は出力を読み取って除きます)。
git rebase origin/<default-branch>
例(デフォルトブランチが master の場合):
git rebase origin/master
rebase 中にコンフリクトが発生した場合は、各ファイルのコンフリクトを解決して git add <file> でステージし git rebase --continue で継続し、断念する場合は git rebase --abort で rebase 前の状態に戻します。
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
--force-with-lease が失敗する場合、他の誰かがリモートブランチを更新しています。
再度 git fetch して状況を確認してください。
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub natsuume/natsuume-cc-marketplace --plugin git-guardrails