Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding redundant branches in Git

Tags:

git

In git is there a way to find out redundant branches which are already in the commit history of a particular/current branch ? So that I can delete those redundant branches without loosing any commits and clean my repository as well ?

like image 634
Ahmed Avatar asked Oct 14 '25 08:10

Ahmed


1 Answers

It turns out to be pretty easy, to get list of all branches merged to master just call:

git branch --merged master

Then you might do following to remove them (use with care):

git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d

I found this solution here.

like image 187
jb. Avatar answered Oct 16 '25 21:10

jb.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!