From cc-arsenal
Sync current branch with base branch using merge (default) or rebase. Handles fork sync, conflict detection, and stash management.
npx claudepluginhub mgiovani/cc-arsenal --plugin cc-arsenal-teamsThis skill is limited to using the following tools:
> **Cross-Platform AI Agent Skill**
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
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