Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
scripts: Add `delete-remote-branches` script
Alexis Sellier committed 2 years ago
commit 4722b9b417015ac0171d0bd3ebbcbcf9b376f433
parent 4176d62e38f174c72e24e7f411f2bf9960a2fa42
1 file changed +22 -0
added scripts/delete-remote-branches.sh
@@ -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