Created
June 18, 2024 07:40
-
-
Save arkon108/a0ccd9cc88bb0d100a9fc90ab6f63421 to your computer and use it in GitHub Desktop.
Git remove local branches which were merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function git-prune-branches() { | |
echo "switching to master or main branch.." | |
git branch | grep 'main\|master' | xargs -n 1 git checkout | |
echo "fetching with -p option..."; | |
git fetch -p; | |
echo "running pruning of local branches" | |
git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -d ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment