Juan Belieni
Posted on August 30, 2021
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 ~/.gitconfig
file:
...
[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
At ~/.gitconfig
:
...
[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:
git del-branches
💖 💪 🙅 🚩
Juan Belieni
Posted on August 30, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.