Valerio Como

← Back to blog

Published on Sat Feb 11 2023 09:20:00 GMT+0000 (Coordinated Universal Time) by Valerio Como

Git: remove branches except main

Keep your git repo clean

Git: remove branches except main

TL;DR

Problem

When you are working on a project for a while, you could have a lot of unused branches. Terminal is your best friend in order to keep your local repo clean.

Solution

Bash is good friend for developers. So, you could use its superpowers and run simple powerful commands.

Explanation

Pipes let you use the output of program as an input for another program. So, the script is a combination of three programs:

BONUS: Git Flow clean up

If you adopt Git Flow as your workflow, you can use this script:

Hope you found this post useful.

Written by Valerio Como

← Back to blog