Git branching strategies - create, switch, merge, rebase, and workflows
When you need to create, switch, merge, or rebase Git branches, this skill handles the entire workflow. It executes branch operations and automatically resolves common conflicts, triggered by explicit requests for branch management tasks.
/plugin marketplace add pluginagentmarketplace/custom-plugin-git-github/plugin install custom-plugin-git-github@pluginagentmarketplace-git-githubThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/branching_config.yamlreferences/BRANCHING_GUIDE.mdscripts/branch_helper.pyProduction-Grade Development Skill | Version 2.0.0
Effective branching and merging strategies for development workflows.
input:
type: object
properties:
operation:
type: string
enum: [create, switch, merge, rebase, delete, list, strategy]
default: list
branch_name:
type: string
pattern: "^[a-zA-Z0-9/_-]+$"
maxLength: 100
strategy:
type: string
enum: [gitflow, github-flow, trunk-based]
options:
type: object
properties:
force:
type: boolean
default: false
dry_run:
type: boolean
default: false
output:
type: object
required: [result, success]
properties:
result:
type: string
success:
type: boolean
branches_affected:
type: array
items:
type: string
warnings:
type: array
rollback_command:
type: string
retry_config:
max_attempts: 2
backoff_ms: [1000, 2000]
retryable:
- lock_file_exists
- network_timeout
non_retryable:
- merge_conflict
- branch_not_found
fallback:
- trigger: merge_conflict
action: abort_and_guide_manual_resolution
command: git merge --abort
- trigger: rebase_conflict
action: abort_and_suggest_merge
command: git rebase --abort
# List branches
git branch # Local branches
git branch -r # Remote branches
git branch -a # All branches
# Create branch
git branch feature-x # Create only
git checkout -b feature-x # Create and switch
git switch -c feature-x # Modern syntax
# Switch branches
git checkout main
git switch main # Modern syntax
# Delete branch
git branch -d feature-x # Safe delete
git branch -D feature-x # Force delete
git push origin --delete feature-x # Delete remote
┌─────────────────────────────────────────────────────────────┐
│ GITFLOW │
├─────────────────────────────────────────────────────────────┤
│ main ●─────────────────●───────────────●──────────► │
│ ↑ ↑ ↑ │
│ release ├─────●───────────┤ │ │
│ │ ↑ │ │ │
│ develop ├──●──┴──●──●──●──┴──●──●──●──●──┴──●──●──────► │
│ │ ↑ ↑ ↑ ↑ ↑ │
│ feature └──┴─────┴─────┴─────┴─────┘ │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ GITHUB FLOW │
├─────────────────────────────────────────────────────────────┤
│ main ●────────●────────●────────●────────●─────────► │
│ \ ↑ \ ↑ \ ↑ │
│ feature \────● \───● \───● │
│ (PR) (PR) (PR) │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ TRUNK-BASED DEV │
├─────────────────────────────────────────────────────────────┤
│ main ●──●──●──●──●──●──●──●──●──●──●──●──●─────────► │
│ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ │
│ (frequent small commits to main) │
└─────────────────────────────────────────────────────────────┘
| Strategy | Command | Use Case |
|---|---|---|
| Fast-Forward | git merge feature | Linear history |
| Three-Way | git merge feature | Diverged branches |
| Squash | git merge --squash feature | Clean history |
| Aspect | Merge | Rebase |
|---|---|---|
| History | Preserves | Linear |
| Safety | Shared branches OK | Never on shared |
| Conflicts | Resolve once | May resolve multiple |
□ 1. Current branch? → git branch
□ 2. Uncommitted changes? → git status
□ 3. Diverged? → git log --oneline main..HEAD
| Error | Cause | Solution |
|---|---|---|
| "already exists" | Branch name taken | Use different name |
| "not fully merged" | Unmerged commits | Use -D or merge first |
| "CONFLICT" | Divergent changes | Resolve manually |
logging:
level: INFO
events:
- branch_created
- merge_completed
- conflict_detected
metrics:
- branches_per_repo
- merge_conflict_rate
feature/user-auth, fix/login-bug"Branches are cheap in Git - use them liberally."
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.