kbrockhoff/brockhoff-tools-claude
bkff-git
plugins/bkff-git/skills/git-sync/SKILL.md
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/kbrockhoff/brockhoff-tools-claude/blob/main/plugins/bkff-git/skills/git-sync/SKILL.md -a claude-code --skill git-syncInstallation paths:
.claude/skills/git-sync/# Sync with Remote
Fetches from origin and integrates changes from a source branch. Automatically chooses rebase (for unpushed branches) or merge (for pushed branches) strategy.
## Usage
```
/bkff:git-sync [source-branch]
```
## Strategy Selection
| Condition | Strategy |
|-----------|----------|
| Branch not pushed to origin | Rebase (clean history) |
| Branch already pushed to origin | Merge (preserve history) |
## Example Output
```
## Sync Complete (Rebase)
### Fetch
- ✓ Fetched from origin
### Strategy
- **Mode**: Rebase (branch not yet pushed)
- **Source**: main
### Result
- **Status**: Up to date with main
```
## Requirements
- Must be run inside a git worktree
- `git` CLI with rerere enabled recommended
- No uncommitted changes
## Implementation
```bash
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PLUGIN_DIR="$(dirname "$(dirname "$SCRIPT_DIR")")"
source "$PLUGIN_DIR/lib/common.sh"
source "$PLUGIN_DIR/lib/git-helpers.sh"
require_worktree
SOURCE_BRANCH="${1:-$(get_main_branch)}"
CURRENT_BRANCH=$(get_current_branch)
# Check for uncommitted changes
if has_changes; then
error_exit "You have uncommitted changes. Commit or stash before syncing."
fi
# Prevent syncing main onto itself
if [[ "$CURRENT_BRANCH" == "$SOURCE_BRANCH" ]]; then
error_exit "Already on $SOURCE_BRANCH. Nothing to sync."
fi
echo "## Sync Process"
echo ""
# FR-018: Fetch from origin
echo "### Fetch"
info "Fetching from origin..."
if git fetch origin --prune; then
echo "- ✓ Fetched from origin"
else
error_exit "Fetch failed. Check network connection."
fi
echo ""
# Verify source branch exists
if ! git rev-parse --verify "origin/$SOURCE_BRANCH" &>/dev/null; then
error_exit "Branch '$SOURCE_BRANCH' not found on origin."
fi
# FR-019: Determine if branch has been pushed
echo "### Strategy"
if is_branch_pushed "$CURRENT_BRANCH"; then
STRATEGY="merge"
echo "- **Mode**: Merge (branch already pushed to o