git-sync-manager-5-safe-branch-operations

Sub-skill of git-sync-manager: 5. Safe Branch Operations.

5 stars

Best use case

git-sync-manager-5-safe-branch-operations is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Sub-skill of git-sync-manager: 5. Safe Branch Operations.

Teams using git-sync-manager-5-safe-branch-operations should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/5-safe-branch-operations/SKILL.md --create-dirs "https://raw.githubusercontent.com/vamseeachanta/workspace-hub/main/.agents/skills/_core/bash/git-sync-manager/5-safe-branch-operations/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/5-safe-branch-operations/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How git-sync-manager-5-safe-branch-operations Compares

Feature / Agentgit-sync-manager-5-safe-branch-operationsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Sub-skill of git-sync-manager: 5. Safe Branch Operations.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 5. Safe Branch Operations

## 5. Safe Branch Operations


Switch branches safely across repositories:

```bash
#!/bin/bash
# ABOUTME: Safe branch switching across repositories
# ABOUTME: Validates branch existence and checks for uncommitted changes

switch_branch() {
    local repo="$1"
    local target_branch="$2"

    if [[ ! -d "$repo/.git" ]]; then
        echo "skip: not a git repo"
        return 1
    fi

    cd "$repo" || return 1

    # Check for uncommitted changes
    if ! git diff --quiet 2>/dev/null || ! git diff --cached --quiet 2>/dev/null; then
        echo "blocked: uncommitted changes"
        return 1
    fi

    # Check if branch exists locally
    if git show-ref --verify --quiet "refs/heads/$target_branch" 2>/dev/null; then
        git checkout "$target_branch" 2>/dev/null
        echo "switched: local branch"
        return 0
    fi

    # Check if branch exists remotely
    if git show-ref --verify --quiet "refs/remotes/origin/$target_branch" 2>/dev/null; then
        git checkout -b "$target_branch" "origin/$target_branch" 2>/dev/null
        echo "switched: created from remote"
        return 0
    fi

    echo "skip: branch not found"
    return 1
}

# Batch branch switch
batch_switch_branch() {
    local target_branch="$1"
    shift
    local repos=("$@")

    echo "Switching to branch: $target_branch"
    echo ""

    for repo in "${repos[@]}"; do
        echo -n "→ $repo: "
        switch_branch "$repo" "$target_branch"
    done
}
```

Related Skills

memory-bridge-operations

5
from vamseeachanta/workspace-hub

Operate and recover the Hermes-to-repo memory bridge: drift checks, quality gate, bridge commits, push verification, and stash recovery when pre-bridge scripts fail after generating outputs.

marine-safety-incidents

5
from vamseeachanta/workspace-hub

Collect, analyze, and report marine safety incident data from 7 global maritime authorities. Use for incident scraping, safety trend analysis, risk assessment, geographic hotspot identification, and marine safety reporting.

worktree-branch-sync-hygiene

5
from vamseeachanta/workspace-hub

Class-level branch, worktree, dirty-main, stash, sync, and hook hygiene for workspace-hub style multi-repo work.

repo-sync

5
from vamseeachanta/workspace-hub

Smart repository synchronization across workspace-hub ecosystem — diagnoses and fixes pull failures (detached HEAD, diverged branches, uncommitted changes)

nested-git-repo-stash-safety

5
from vamseeachanta/workspace-hub

How to safely stash changes in a parent repo containing dirty nested git repositories

multi-repo-sync-diagnosis-repair

5
from vamseeachanta/workspace-hub

Diagnose and repair failed pulls across multi-repo ecosystems with stale locks, submodule conflicts, and untracked files

multi-repo-sync-diagnosis-and-repair

5
from vamseeachanta/workspace-hub

Systematic approach to diagnosing and repairing failures across a multi-repo workspace

multi-repo-branch-hygiene-at-scale

5
from vamseeachanta/workspace-hub

Systematic approach to cleaning stale branches, resolving merge conflicts, and syncing multiple repos

git-worktree-cleanup-and-branch-reconciliation

5
from vamseeachanta/workspace-hub

Systematic process for cleaning up stale git worktrees, resolving merge conflicts in diverged branches, and reconciling branch state across multiple repositories.

git-worktree-cleanup-and-branch-hygiene

5
from vamseeachanta/workspace-hub

Systematic approach to cleaning up stale git worktrees, orphan branches, and branch hygiene at scale across multiple repos

workspace-hub-sync-root-churn-catchup

5
from vamseeachanta/workspace-hub

Catch up workspace-hub root changes that continue to appear during repo sync because live review/agent processes keep writing files after commits

workspace-hub-sync-concurrent-writer-blocks

5
from vamseeachanta/workspace-hub

Handle repository_sync cleanup when workspace-hub root is being mutated by concurrent Codex/Codex/Gemini sessions.