Created
December 21, 2023 16:56
-
-
Save rydurham/61e1ae3ccf353524077d696cb86f8245 to your computer and use it in GitHub Desktop.
Git - Purge Old Branches
This file contains 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
# https://stevenharman.net/git-clean-delete-already-merged-branches | |
git_purge() { | |
# have any arguments been passed? | |
if [ $# -gt 0 ];then | |
BRANCH=$1 | |
echo $BRANCH | |
git checkout $BRANCH | |
git branch --merged $BRANCH | grep -v "\* $BRANCH" | xargs -n 1 git branch -d | |
git remote prune origin | |
else | |
echo "No branch specified" | |
fi | |
} | |
alias gp=git_purge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment