pruned unneeded branches

This commit is contained in:
Hamza417
2024-11-11 21:16:30 +05:30
parent 291f0a0235
commit 3c5a13263a
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,23 @@
@echo off
REM Fetch the latest branches from the remote
git fetch --prune
REM Get a list of local branches
for /f "tokens=*" %%i in ('git branch --format="%%(refname:short)"') do (
setlocal enabledelayedexpansion
set "local_branch=%%i"
REM Check if the local branch exists on the remote
set "exists=false"
for /f "tokens=*" %%j in ('git branch -r --format="%%(refname:short)" ^| sed "s|origin/||"') do (
if "%%j"=="!local_branch!" (
set "exists=true"
)
)
REM If the branch does not exist on the remote, delete it
if "!exists!"=="false" (
git branch -d "!local_branch!"
)
endlocal
)