Last active
November 22, 2021 21:11
-
-
Save earlonrails/6994990 to your computer and use it in GitHub Desktop.
delete merged branches in git, if you want to.
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
merged_branches(){ | |
local current_branch=$(git rev-parse --abbrev-ref HEAD) | |
for branch in $(git branch --merged | cut -c3-) | |
do | |
echo "Branch $branch is already merged into $current_branch." | |
echo "Would you like to delete it? [Y]es/[N]o " | |
read REPLY | |
if [[ $REPLY =~ ^[Yy] ]]; then | |
git branch -d $branch | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@krone it looks like it's only for deleting local branches. if you want to delete from remote as well, theoretically adding "git push origin :$branch" after line 9 should work