Swamp in action - Finding relevant branches in git

I had written a small script sometime in 2014 for me to separate out the stale branches from the most relevant branches in a git repository.

Today, I was working on a bunch of repositories. I wanted to figure out the recent most branches, and their relevance in relation to master. It hit me out of nowhere and I remembered the script I had written earlier.

First, see the script in action:


Alternatively, you can view it on asciinema.


Right off the bat, I can see that


#4 branches are all merged into master (+0) already.


I could probably nuke a few of these branches.

#The branches being actively worked on are:


and probably


All right. Now I know which branch I want to branch off of.

#How to install?

A quick and easy install is using this gist:

curl https://gist.githubusercontent.com/algogrit/3fd5b9ca88dd08ec5f6ce4d5e2c4c719/raw | sh

The content of the install script is simply:

#!/usr/bin/env bash

mkdir -p /usr/local/bin
curl -s https://raw.githubusercontent.com/algogrit/Script-BackUp/swamp-0.3/OS%20X/Custom-Git-Commands/git-swamp > /usr/local/bin/git-swamp
chmod 744 /usr/local/bin/git-swamp

If you have /usr/local/bin in your PATH already, then you can starting using it as:

git swamp

I hope you find it as useful as the fun I had in writing it.

Latest Posts