Skip to content

Instantly share code, notes, and snippets.

@dhbradshaw
Created February 28, 2022 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhbradshaw/d1c51f251c6e5ed1ff3ecd07c7676a17 to your computer and use it in GitHub Desktop.
Save dhbradshaw/d1c51f251c6e5ed1ff3ecd07c7676a17 to your computer and use it in GitHub Desktop.
Delete all redundant git branches
# 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