Claus Witt dot com

webdeveloper

At work, our git workflow forces every issue in jira to be created in a new tracking branch. The naming convention then makes sure that the release manager can identify issue and code, and their relation.

However this means that either the release manager needs to remove unused tracking branches, or the branche count on our remote repo goes through the roof. Until now, it has been a chore that has been postponed, until today.

My colleague Jesper Rasmussen created an issue in Jira today about creating an automatizeable process to remove unused tracking branches. I jumped on the idea as soon as I saw it, since it has been bothering me for some time.

Google, git and bash to the rescue.

My idea was to create a bash script, make it list all tracking branches which is already merged to master, and then go through that list, and remove all the tracking branches.

The resulting script looks like this

I have a alias for the script and can call it from any git repo I have with cleanupBranches

blog comments powered by Disqus