diff --git a/README.md b/README.md index 864b60a..d409c75 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Checkout Old Version Of A File](git/checkout-old-version-of-a-file.md) - [Checkout Previous Branch](git/checkout-previous-branch.md) +- [Clean Out All Local Branches](git/clean-out-all-local-branches.md) - [Delete All Untracked Files](git/delete-all-untracked-files.md) - [Dry Runs in Git](git/dry-runs-in-git.md) - [Intent To Add](git/intent-to-add.md) diff --git a/git/clean-out-all-local-branches.md b/git/clean-out-all-local-branches.md new file mode 100644 index 0000000..d7d5621 --- /dev/null +++ b/git/clean-out-all-local-branches.md @@ -0,0 +1,17 @@ +# Clean Out All Local Branches + +Sometimes a project can get to a point where there are so many local +branches that deleting them one by one is too tedious. This one-liner can +help: + +``` +$ git branch --merged master | grep -v master | xargs git branch -d +``` + +This won't delete branches that are unmerged which saves you from doing +something stupid, but can be annoying if you know what you are doing. If you +are sure you want to wipe everything, just use `-D` like so: + +``` +$ git branch --merged master | grep -v master | xargs git branch -D +```