Skip to content

Instantly share code, notes, and snippets.

@kinwahlai
Last active April 29, 2022 08:32
Show Gist options
  • Save kinwahlai/8e526cc0c504da48b02a85a689839478 to your computer and use it in GitHub Desktop.
Save kinwahlai/8e526cc0c504da48b02a85a689839478 to your computer and use it in GitHub Desktop.
How to Delete Already Merged Git Branches
# 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