Back to Skills

git-sync

verified

Branch to sync from (default: main)

View on GitHub

Marketplace

brockhoff-tools

kbrockhoff/brockhoff-tools-claude

Plugin

bkff-git

Repository

kbrockhoff/brockhoff-tools-claude

plugins/bkff-git/skills/git-sync/SKILL.md

Last Verified

January 24, 2026

Install Skill

Select agents to install to:

Scope:
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-sync

Installation paths:

Claude
.claude/skills/git-sync/
Powered by add-skill CLI

Instructions

# 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

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3830 chars