Last active
April 29, 2022 08:32
-
-
Save kinwahlai/8e526cc0c504da48b02a85a689839478 to your computer and use it in GitHub Desktop.
How to Delete Already Merged Git 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
# To delete all local branches that are already merged into the currently checked out branch: | |
git branch --merged | grep -i -v -E "master|develop"| xargs git branch -d | |
# To delete all local branches that no longer exist on the Remote | |
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