File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ name : sync-git
3+ description : Sync local repo with upstream, clean up branches and remotes
4+ disable-model-invocation : true
5+ allowed-tools : Bash
6+ ---
7+
8+ Run ` bash scripts/synch-git.sh ` and report the output to the user.
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ echo " === Syncing main with upstream ==="
5+ git fetch upstream main
6+ git checkout main
7+ git merge upstream/main --ff-only
8+
9+ echo " "
10+ echo " === Pruning stale remote-tracking references ==="
11+ git fetch origin --prune
12+ git fetch upstream --prune
13+
14+ echo " "
15+ echo " === Deleting local branches merged into main ==="
16+ merged=$( git branch --merged main | grep -v ' ^\*\|main' || true)
17+ if [ -n " $merged " ]; then
18+ echo " $merged " | xargs git branch -d
19+ else
20+ echo " No merged branches to delete."
21+ fi
22+
23+ echo " "
24+ echo " === Done ==="
25+ git branch
You can’t perform that action at this time.
0 commit comments