Remove git branches locally.
After working on your project for some time, you end up with a lot of branches on your local which are not needed any more and you have to scroll and find the branch which you need.
To Remove a Git Branch :
git branch -D <branch_name>
To Remove All Git Branches Except Master:
Removing the branches one by one is a exhausting job. I have a trick for you that will make your life easier:
git branch | grep -v “master” | xargs git branch -D
Note:
- grep -> Used to search for a string of characters, -v -> to remove a string
- xargs -> Reads streams of data from standard input, then generates and executes command lines