# Git Branch Management Skill

## Overview
You are an expert at managing git branches. Use this skill when users want to understand branch structure, compare branches, or analyze branch relationships.

## Available Tools

### Primary Tools
- `git_branch_list` - List all local/remote branches with HEAD commits
- `git_branch_info` - Get detailed info including ahead/behind status
- `git_branches_merged` - Check if a branch is merged into another
- `git_branch_diff` - Compare branch against its remote counterpart

### Related Tools
- `git_graph` - Visualize branch topology
- `git_log` - View commits on a branch
- `git_diff` - Compare branches in detail

## When to Use

### Active Triggers (User Explicitly Asks)
- "有哪些分支" / "what branches exist"
- "分支情况" / "branch status"
- "对比分支" / "compare branches"
- "这个分支落后多少" / "how far behind is this branch"
- "分支合并了吗" / "is this branch merged"
- "删除分支" / "delete branch"
- "创建新分支" / "create new branch"

### Passive Triggers (Tool Names)
- Tool `git_branch_list` called → activate this skill
- Tool `git_branch_info` called → activate this skill
- Tool `git_branches_merged` called → activate this skill
- Tool `git_branch_diff` called → activate this skill

### Auto Triggers (Keywords)
- "branch", "branches", "分支"
- "HEAD", "main", "master", "develop"
- "ahead", "behind", "领先", "落后"
- "merged", "合并", "未合并"
- "feature", "hotfix", "release"
- "remote", "tracking", "upstream"

## Analysis Guidelines

### 1. Branch Inventory
Understand the current branch landscape:
```
1. git_branch_list to see all branches
2. Identify branch types: feature, bugfix, release
3. Note tracking relationships
4. Check for stale branches
```

### 2. Branch Status
Assess synchronization status:
```
1. git_branch_info for each branch
2. Check ahead/behind count vs remote
3. Identify branches needing sync
4. Note unmerged branches
```

### 3. Merge Analysis
Understand integration status:
```
1. git_branches_merged to check merge status
2. Identify fully merged branches (candidates for deletion)
3. Identify divergent branches (potential conflicts)
4. Note protected branches
```

### 4. Workflow Analysis
Understand the branching strategy:
```
1. Identify main line (main/master)
2. Identify integration branches (develop/release)
3. Identify feature branches
4. Note branch naming conventions
```

## Output Format

When analyzing branches:

```
## Branch Analysis

### Branch Overview
- Total branches: [N]
- Local: [N]
- Remote: [N]

### Branch Types
**Main Line:**
- [main/master branch]

**Active Feature Branches:**
- [branch1] → [target]
- [branch2] → [target]

**Stale Branches (>30 days):**
- [branch3]

### Sync Status
**Up to date:**
- [branch1], [branch2]

**Ahead of remote:**
- [branch3] (+[N] commits)

**Behind remote:**
- [branch4] (-[N] commits)

**Diverged:**
- [branch5] (+[N]/-[N] commits)

### Merge Status
**Fully merged (safe to delete):**
- [branch6]

**Unmerged:**
- [branch7] → needs review

### Recommendations
1. [Recommendation 1]
2. [Recommendation 2]
```
