mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-21 10:30:41 +08:00
scripts: Add delete-remote-branches script
This is useful for cleaning up remote branches that are no longer used.
This commit is contained in:
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# Delete all remote branches that don't have a local copy.
|
||||
|
||||
remote="rad"
|
||||
|
||||
# Iterate over all remote branches.
|
||||
for branch in $(git branch -r --format "%(refname:short)"); do
|
||||
# Extract the branch name without the "$remote/" prefix.
|
||||
branch=${branch#"$remote/"}
|
||||
# Never delete the master branch.
|
||||
if [ "$branch" == "master" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if the branch doesn't exist locally.
|
||||
if ! git rev-parse --quiet --verify "$branch" >/dev/null; then
|
||||
git push -o "no-sync" $remote --delete "$branch"
|
||||
echo "Deleted '$branch'"
|
||||
fi
|
||||
done
|
||||
|
||||
rad sync --announce
|
||||
Reference in New Issue
Block a user