From a6f0095f2925f8683a3bfea2956e4cac96dafab5 Mon Sep 17 00:00:00 2001 From: Pranav Kumar Mishra <62562712+pranavmishra90@users.noreply.github.com> Date: Sun, 10 Aug 2025 17:15:55 -0500 Subject: [PATCH] feat: add script to clean local branches, removing the branches that have already been merged --- .datalad/procedures/clean-local-branches.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 .datalad/procedures/clean-local-branches.sh diff --git a/.datalad/procedures/clean-local-branches.sh b/.datalad/procedures/clean-local-branches.sh new file mode 100755 index 0000000..504630b --- /dev/null +++ b/.datalad/procedures/clean-local-branches.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +git fetch --prune + +current_branches=$(git branch --format='%(refname:short)') +echo "Current local branches:" +echo "$current_branches" + +echo "Deleting local branches that are already merged into main or master..." +branches=$(git branch -vv | grep ': gone]' | awk '{print $1}') + +if [ -n "$branches" ]; then + echo "$branches" | xargs git branch -d +fi + +echo "done" \ No newline at end of file