7
Remove all git branches except master
source link: https://pawelgrzybek.com/remove-all-git-branches-except-master/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Remove all git branches except master
Published: 2020.12.20 | 1 minutes read
After working on a project for a while, it’s easy to end up with a lot of legacy branches that are not needed anymore. Removing them one by one would be a cumbersome task. Luckily you don’t have to!
git branch | grep -v "master" | xargs git branch -D
Let me explain each part:
git branch
— list all branchesgrep -v "master"
— removemaster
from the listxargs git branch -D
— executegit branch -D
against remaining branches
So helpful, isn’t it? Catch you next time 👋
If you liked this article, please share it on Twitter.
Copyright © 2020 Pawel GrzybekRecommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK