Ben Halpern
Posted on April 19, 2022
I frequently search for the code to delete all local branches except master so I can copy/paste the result, but I always get the "master" version of this — which doesn't help the copy/paste part of it.
$ git branch | grep -v "main" | xargs git branch -D
Here's hoping this becomes the top result so I can speed up my process by one second. We all know I'll never actually remember the command.
Happy coding!
💖 💪 🙅 🚩
Ben Halpern
Posted on April 19, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.