Mid From PDF Version Control Git & GitHub

How do you clean up old branches automatically?

Old branches can clutter your repo. You can clean them locally and remotely.

Commands:

To delete merged branches locally:

git branch --merged main | grep -v "main" | xargs git branch -d

  • To prune deleted remote branches:

git fetch --prune

  • Example:

fter several months, your repo has 50 old feature branches. You can prune them

utomatically in CI or periodically with these commands.

More from Developer Essentials

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details