Created
September 11, 2019 05:13
-
-
Save pingcheng/136f404e86761491f7b813a5632b4720 to your computer and use it in GitHub Desktop.
Delete merged branches on local
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
#!/bin/sh | |
# get all merged branch | |
branches=$(git branch --merged master | grep -v '^[ *]*master$') | |
# define colors | |
GREEN='\033[0;32m' | |
YELLOW='\033[1;33m' | |
LIGHT_GRAY='\e[90m' | |
NC='\033[0m' | |
# if no branches are need to clear, just exit | |
if [ -z "$branches" ] | |
then | |
echo "${GREEN}No merged branches to remove${NC}" | |
exit 0 | |
fi | |
# delete each merged branch | |
for branch in $branches | |
do | |
echo "${LIGHT_GRAY}Deleting merged branch - ${YELLOW}${branch}${NC}" | |
git branch -d $branch | |
done | |
echo "${GREEN}Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment