Files
gartenmanager/.claude/scripts/git-switch.sh
Faultier314 5b00036951 docs: update CLAUDE.md and add git helper scripts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-06 07:56:33 +02:00

37 lines
1008 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# git-switch.sh Branch wechseln oder erstellen, remote aktualisieren
#
# Verwendung:
# bash .claude/scripts/git-switch.sh <branch> wechseln (pull wenn vorhanden)
# bash .claude/scripts/git-switch.sh <branch> create neu aus aktuellem Branch
# bash .claude/scripts/git-switch.sh <branch> from <base> neu aus <base>
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)"