Sometimes, deleting branches that we are no longer working on can be tedious. For this, you can create an alias to do the hard work for you.
All git aliases are located at the
... [alias] cm = commit # Example alias
The custom alias we will create will delete all branches except master and the current one:
git branch | grep -v "master" | grep -v "^*" | xargs git branch -d
... [alias] del-branches = !git branch | grep -v "master" | grep -v "^*" | xargs git branch -d
Finally, you just have to call the alias at your repository directory as a normal git command: