- Andrew Hagedorn
- Articles
- Delete Local Git Branches
Delete Local Git Branches
This is an archive of the random commands I have found useful. You may or may not, but the next time I need them I will know where to find them.
My development workflow doesn't really necessitate that I clean up my local branches very often. I mostly ignore them until one day I do git branch
and the result is taller than my terminal. Rather than think to hard about it, I instead immediately declare bankruptcy and run this command to delete all my local branches:
function deletebranches() {
git branch | egrep -v "(^*)" | xargs git branch -d;
}
An important thing to note is the -d
. In its lower case form it will only delete local branches that are fully merged into its upstream branch. If you are really feeling bold you can instead use -D
which will force delete all your local branches.
Other Posts
Technology
- React SSR at Scale
- TravisCI, TeamCity, and Kotlin
- The Good and the Bad of Cypress
- Scaling Browser Interaction Tests
- Exploring Github Actions
- Scope and Impact
- Microservices: Back to the Future