To delete branches already merged:
git branch --merged | grep -v '^[ *]*main$' | xargs git branch -d
Where main
is trunk commonly master
or main
.
If you are looking to do a deep clean where branches are not merged then you can use the D
switch instead of d
.
Have you made a mistake? Recover your branch by getting it's SHA and checking it out.
git reflog --no-abbrev
git checkout -b <your-branch> <sha>
Top comments (0)