Created
February 28, 2022 15:45
-
-
Save dhbradshaw/d1c51f251c6e5ed1ff3ecd07c7676a17 to your computer and use it in GitHub Desktop.
Delete all redundant 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
# Delete all redundant git branches | |
# 1. `git branch` lists all the branches | |
# 2. `xargs -L1` consumes the pipe output one line at a time, feeding it as an an arg to the target command | |
# 3. `git branch -d` deletes the branches that are redundant (already merged). | |
# Note: this print results for each branch, either | |
# saying it's deleted or that you need to use -D to delete it because it's not redundant. | |
git branch | xargs -L1 git branch -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment