#!/usr/bin/env bash # git-switch.sh – Branch wechseln oder erstellen, remote aktualisieren # # Verwendung: # bash .claude/scripts/git-switch.sh – wechseln (pull wenn vorhanden) # bash .claude/scripts/git-switch.sh create – neu aus aktuellem Branch # bash .claude/scripts/git-switch.sh from – neu aus set -euo pipefail BRANCH="${1:?'Branch-Name fehlt'}" MODE="${2:-switch}" BASE="${3:-}" ROOT="$(git rev-parse --show-toplevel)" cd "$ROOT" case "$MODE" in switch) git fetch origin "$BRANCH" 2>/dev/null || true git checkout "$BRANCH" 2>/dev/null || git checkout -b "$BRANCH" git pull origin "$BRANCH" 2>/dev/null || true ;; create) git checkout -b "$BRANCH" git push -u origin "$BRANCH" ;; from) BASE="${3:?'Basis-Branch fehlt'}" git fetch origin "$BASE" git checkout -b "$BRANCH" "origin/$BASE" git push -u origin "$BRANCH" ;; esac echo "Aktiver Branch: $(git branch --show-current)"