一键导入
git-sync
Sync current branch with base branch using merge (default) or rebase. Handles fork sync, conflict detection, and stash management.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Sync current branch with base branch using merge (default) or rebase. Handles fork sync, conflict detection, and stash management.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Headless browser automation CLI optimized for AI agents. Uses snapshot + refs system for 93% less context overhead vs Playwright. Purpose-built for web testing, form automation, screenshots, and data extraction.
Manage a gitflow branching workflow — starting and finishing feature, release, and hotfix branches; cutting versioned releases with changelog generation; coordinating emergency hotfixes directly to production; and keeping long-lived branches in sync. Activates when users mention gitflow, feature/release/hotfix branches, cutting a release, branching strategy, promoting an integration branch to production, tagging a version, or rolling back a live release. Also reaches for it when the user says "ship it", "promote dev to main", or "we need to hotfix prod" without naming gitflow. Skip for general git mechanics (commit messages, merge conflicts, interactive rebase, git education) or CI-failure debugging unrelated to a release.
Fixes a bug through test-driven debugging — reproduces it with a failing test, locates the root cause with evidence (file:line), then applies the smallest fix that resolves it without refactoring unrelated code. Use when the user wants to fix a bug, debug an issue, resolve an error, or investigate a failing test. Not for building new functionality (use implement-feature) or restructuring working code with no bug involved (use refactor).
Implements a new feature end-to-end as a senior staff engineer would — discovers project conventions, researches current best practices, drafts a plan for approval, then builds it with parallel subagents that reuse existing code, skip speculative abstractions, and verify with tests before completion. Use when the user wants to implement, build, add, or ship new functionality (a feature, endpoint, component, module, or integration) — not for fixing an existing bug (use fix-bug) or restructuring code that already works (use refactor).
Restructures existing code without changing its behavior — maps callers and test coverage, adds characterization tests where coverage is thin, then applies the change in small steps verified against the full test suite after each one. Use when the user wants to refactor, extract a method or class, simplify logic, reduce duplication, improve naming, restructure modules, or pay down technical debt in code that already works. Not for adding new functionality (use implement-feature) or fixing broken behavior (use fix-bug).
Runs a comprehensive multi-agent code review of a PR, commit, or the whole codebase across six dimensions (correctness, performance, code style, test coverage, error handling, and simplicity/over-engineering) and returns a severity-ranked report with file:line findings and fix suggestions. Use when the user wants a thorough code review, asks to review a PR or diff, or wants over-engineered code flagged for simplification. Analysis only, identifying issues without modifying code, committing, or running tests. Not for a security-focused audit (use review-security) or a visual/UX design critique (use review-design).
| name | git-sync |
| description | Sync current branch with base branch using merge (default) or rebase. Handles fork sync, conflict detection, and stash management. |
| metadata | {"author":"mgiovani","version":"1.0.0","source":"https://github.com/mgiovani/skills"} |
| disable-model-invocation | true |
| argument-hint | [--rebase] [--base main] [--upstream] [--stash] |
| allowed-tools | ["Bash(git *)","Read","AskUserQuestion"] |
Cross-Platform AI Agent Skill This skill works with any AI agent platform that supports the skills.sh standard.
Sync the current branch with its base or upstream branch. Defaults to merge to preserve history; rebase is opt-in only.
CRITICAL: Only sync based on what git status and git log actually show:
git status and git branch before any sync operationRun the following to understand current branch state:
# Current branch and status
git branch --show-current
git status --porcelain
# Remote tracking info
git remote -v
git fetch --dry-run 2>&1 || true
# Commits ahead/behind base
git log --oneline HEAD..origin/main 2>/dev/null | head -20
git log --oneline origin/main..HEAD 2>/dev/null | head -20
Also check:
git log origin/<branch>..HEAD — if error, branch is local-only)gh pr view --json baseRefName -q .baseRefName 2>/dev/null or ask user)Determine sync strategy:
Merge (default) — Use when:
--rebaseRebase (opt-in) — Use only when:
--rebase, OR--rebase is passedFork sync (--upstream) — Use when:
git fetch upstream && git merge upstream/<base>Display the detected state and proposed strategy clearly before proceeding:
Current branch: feature/my-feature
Base branch: main
Strategy: merge (default)
Commits behind: 5
Commits ahead: 2
Dirty tree: no
If user did not provide --base, infer base from:
gh pr view --json baseRefName (if GitHub CLI available)git config branch.<name>.mergeAskUserQuestionHandle dirty working tree:
--stash flag: run git stash push -m "git-sync auto-stash" before sync--stash: abort with clear message asking user to commit, stash, or use --stashFetch latest from remote:
git fetch origin
# For fork sync:
git fetch upstream
Re-check divergence after fetch to report accurate numbers
Merge strategy:
git merge origin/<base>
Rebase strategy (local-only branch):
git rebase origin/<base>
Rebase strategy (pushed branch — warn user first):
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 yes:
git rebase origin/<base>
git push --force-with-lease origin <branch>
On merge/rebase conflict:
git diff --name-only --diff-filter=U to list conflicting filesgit merge --continue or git rebase --continuegit merge --abort or git rebase --abortAfter successful sync:
# Show new position
git log --oneline -5
git log --oneline origin/<base>..HEAD | wc -l
Report:
git stash pop if --stash was used)git rerere if conflicts were presentPop stash if it was auto-stashed:
git stash pop
--rebase: Use rebase instead of merge--base <branch>: Specify the base branch (default: auto-detect)--upstream: Sync from upstream remote instead of origin (fork workflow)--stash: Auto-stash dirty changes before sync, pop after--force-with-lease instead of --force to prevent overwriting others' workupstream remote to be configured (git remote add upstream <url>)# Sync with main using merge (default)
/git-sync
# Sync with develop branch
/git-sync --base develop
# Rebase onto main (local-only branch)
/git-sync --rebase
# Sync, stashing local changes first
/git-sync --stash
# Fork sync: pull upstream changes into your fork
/git-sync --upstream --base main