> ## Content Index
> Fetch the complete content index at: https://catalins.tech/llms.txt
> Use this file to discover other available public pages before exploring further.

# How To Delete All Local Git Branches In One Go
- URL: https://catalins.tech/how-to-delete-all-local-git-branches-in-one-go/
- Published: 2021-04-16T15:06:00.000Z
- Updated: 2022-10-14T04:48:10.000Z
- Author: Catalin Pit
- Tags: Git

Sometimes, you might want to delete all your local branches from a project. Doing it one by one might be very tedious when you have lots of branches.

Thus, with the command below, you can delete all your local branches except `main`:

```
git branch | grep -v "main" | xargs git branch -D

```

Of course, you can replace the `main` branch with any other branch.

---

Additionally, you might be interested in [Git Aliases](https://catalins.tech/git-aliases-what-are-they-and-how-to-use-them). The aliases will improve your experience significantly, and it is going to save you time as well.