git-sync skill
自動的なstash処理を伴うmergeまたはrebase戦略を使用して、フィーチャーブランチをベースブランチまたはupstreamブランチと同期します。
- GitHubスター
- 8
- ファイル
- 3
- 最終コミット
- 2026年10月28日
- ライセンス
- MIT
- 許可されたツール
- —
git-sync skillは何をしますか
git-syncはAgent Skillsです。 自動的なstash処理を伴うmergeまたはrebase戦略を使用して、フィーチャーブランチをベースブランチまたはupstreamブランチと同期します。.
skillのSKILL.mdから生成された要約。
git-sync skill について
git-syncは、Gitリポジトリで作業する開発者が、フィーチャーブランチをmainやdevelopブランチの最新状態に保つためのツールです。mergeまたはrebase戦略を使用して、ベースブランチまたはupstreamブランチからの変更を現在の作業ブランチに取り込むプロセスを自動化します。このツールは、正式なリリース管理やホットフィックスの昇格ではなく、アドホックなブランチ更新を目的として設計されています。
エージェントがこのSKILLをロードすると、git statusとgit logを使用して現在のブランチの状態を調査することから始まる、マルチフェーズのワークフローを実行します。GitHub CLIまたはローカルのgit設定を通じて、ベースブランチを自動的に検出できます。データの損失を防ぐため、このSKILLは--stashフラグを使用して、同期前に未コミットの変更を一時的に保存し、プロセスが完了した後にそれらをpopすることができます。標準的なgitコマンドに依存しており、すでにリモートにプッシュされたブランチに対してrebaseが要求された場合には、特定の警告を表示します。
ユーザーは、履歴を書き換えるための--rebase、ターゲットブランチを指定する--base、またはフォークのupstreamリモートから同期する--upstreamなどの引数を使用して、操作をカスタマイズできます。mergeまたはrebase中にコンフリクトが発生した場合、このSKILLは関連する特定のファイルを特定し、手動での解決を可能にするために停止します。
エージェントができること
- 1mainブランチでフィーチャーブランチを更新デフォルトのmerge戦略を使用して、現在の作業ブランチをmainブランチと同期します。
- 2特定のブランチへのrebaserebaseを使用して、developブランチの最新の変更の上にローカルのコミットを適用します。
- 3upstreamからフォークを同期ローカルのフォークを最新の状態に保つために、upstreamリモートから最新の変更を取り込みます。
- 4ローカルの変更を保持しながら同期エラーを避けるために未コミットの作業を自動的にstashしながら、ブランチの同期を実行します。
skill の SKILL.md から作成されています。すべてのユースケースは、その引用と照合されています。
git-sync skillのインストール方法
各コマンドはskillフォルダをクライアントのskillsディレクトリにコピーします。読み込むには、クライアントを再起動するか新しいセッションを開始してください。プラグインにgit-sync skillをインストールする
/plugin marketplace add mgiovani/cc-arsenal /plugin install cc-arsenal@cc-arsenal-marketplace
Claude Codeにgit-sync skillをインストールする
~/.claude/skills/git-sync/SKILL.md
$ npx degit mgiovani/cc-arsenal/skills/git-sync ~/.claude/skills/git-syncClaude Code (project)にgit-sync skillをインストールする
.claude/skills/git-sync/SKILL.md
$ npx degit mgiovani/cc-arsenal/skills/git-sync .claude/skills/git-syncCodexにgit-sync skillをインストールする
~/.agents/skills/git-sync/SKILL.md
$ npx degit mgiovani/cc-arsenal/skills/git-sync ~/.agents/skills/git-syncGemini CLIにgit-sync skillをインストールする
~/.gemini/skills/git-sync/SKILL.md
$ npx degit mgiovani/cc-arsenal/skills/git-sync ~/.gemini/skills/git-syncClaude.aiにgit-sync skillをインストールする
npx degit mgiovani/cc-arsenal/skills/git-sync git-sync && zip -r git-sync.zip git-sync # claude.ai → Customize → Skills → + → Create skill → Upload a skill → git-sync.zip
SKILL.md
GitHubで表示Git Sync
Sync the current branch with its base or upstream branch. Defaults to merge to preserve history; rebase is opt-in only. Only ever act on what git status and git log actually show: never guess branch state or conflicts.
Workflow
Phase 1: Detect & Decide
Run the following to understand current branch state:
git branch --show-current
git status --porcelain
git remote -v
git log --oneline HEAD..origin/main 2>/dev/null | head -20
git log --oneline origin/main..HEAD 2>/dev/null | head -20
Also check whether the branch is pushed to remote (git log origin/<branch>..HEAD: an error means local-only).
Determine the base branch once, and reuse the result for the rest of the run:
- User passed
--base <branch>: use it. - Otherwise
gh pr view --json baseRefName -q .baseRefName 2>/dev/null(if an open PR exists). - Otherwise
git config branch.<name>.merge. - Otherwise ask the user which base branch to use.
Determine sync strategy:
Merge (default): use when the branch has been pushed to remote, the user did not pass --rebase, or you are unsure.
Rebase (opt-in): use only when the user explicitly passed --rebase.
Fork sync (--upstream) syncs from the upstream remote instead of origin: git fetch upstream && git merge upstream/<base>.
Display the detected state and proposed strategy before proceeding:
Current branch: feature/my-feature
Base branch: main
Strategy: merge (default)
Commits behind: 5
Commits ahead: 2
Dirty tree: no
Phase 2: Pre-sync Safety
- Dirty working tree: with
--stash, rungit stash push -m "git-sync auto-stash"before syncing. Without--stash, abort and tell the user to commit, stash, or re-run with--stash. - Fetch latest:
git fetch origin(andgit fetch upstreamfor fork sync). - Re-check divergence after fetch so the numbers you report are accurate, not the pre-fetch snapshot.
Phase 3: Execute & Report
Merge: git merge origin/<base>
Rebase, local-only branch: git rebase origin/<base>
Rebase, pushed branch: warn before rewriting shared history:
WARNING: This branch has been pushed to remote.
Rebasing will require a force-push, which rewrites history.
This is ONLY safe if no one else has pulled this branch.
Proceed? [y/N]
If confirmed:
git rebase origin/<base>
git push --force-with-lease origin <branch>
On merge/rebase conflict, do not guess how to resolve them:
git diff --name-only --diff-filter=Uto list conflicting files.- Report the exact file list, e.g.:
Conflicts in 2 files: src/api/client.ts src/api/types.ts Resolve manually, then run `git merge --continue` (or `git rebase --continue`). Or run `git merge --abort` (or `git rebase --abort`) to back out. - Stop and wait. Do not attempt automatic resolution.
After a successful sync:
- If a stash was auto-created in Phase 2, pop it now:
git stash pop. If the pop itself conflicts, report those conflicting files the same way as a merge conflict. - Gather real numbers, don't estimate:
git log --oneline -5 git log --oneline origin/<base>..HEAD | wc -l - Report, using only values from the commands above:
Include whether force-push was used, and mentionSynced feature/my-feature onto main (merge). Now 2 commits ahead of main, 0 behind. Stash popped cleanly.git rerereif conflicts occurred during this run.
Argument Parsing
--rebase: use rebase instead of merge--base <branch>: specify the base branch (default: auto-detect)--upstream: sync fromupstreamremote instead oforigin(fork workflow)--stash: auto-stash dirty changes before sync, pop after
Important Notes
- Never force push to main/master, regardless of flags or user insistence.
- Merge is the safe default for shared branches; only rebase branches you're sure are local-only or where the user explicitly accepted the force-push warning.
- Use
--force-with-lease, never bare--force, so a rebase-push can't clobber someone else's commits. - Fork workflow requires the
upstreamremote to already be configured (git remote add upstream <url>).
Examples
# Sync with main using merge (default)
/git-sync
# Sync with develop branch
/git-sync --base develop
# Rebase onto main (will warn if branch is already pushed)
/git-sync --rebase
# Sync, stashing local changes first
/git-sync --stash
# Fork sync: pull upstream changes into your fork
/git-sync --upstream --base main
このスキルのファイル
3git-sync skillに関する質問
Claude Codeにgit-sync skillをインストールするには
npx degit mgiovani/cc-arsenal/skills/git-sync ~/.claude/skills/git-syncを実行してください。Claude Codeは~/.claude/skills(すべてのプロジェクト)または.claude/skills(単一プロジェクト)からskillsを読み込み、説明がタスクに一致する場合にskillを使用します。
git-sync skillはどのクライアントで使用できますか
Agent Skills形式を読み込むすべてのクライアントで使用できます: Claude Code、Codex、Gemini CLI、claude.ai(ZIPとしてアップロード)。skill内のスクリプトは、クライアントがコード実行を許可した場合にのみ実行されます。
特定のベースブランチとブランチを同期するにはどうすればよいですか?
--baseフラグを使用してベースブランチを指定できます。例:/git-sync --base develop
このツールを使用して、フォークしたリポジトリをオリジナルリポジトリと同期できますか?
はい、--upstreamフラグを使用すると、originの代わりにupstreamリモートから同期できます。
ワーキングディレクトリにコミットしていない変更がある場合はどうなりますか?
--stashフラグを使用すると、ツールは同期前に変更を自動的にstashし、プロセス完了後にそれらをpopします。