hassek

Remember

My code snippets

When working on bigger teams with multiple branches is very common that old branches stay created. To detect those branches easily git comes with the command:

git fetch -p
git branch --merged

* master
the-everlasting-story
that-guy-that-never-deletes-the-branch

Be sure to update your local branches! That’s why we are running git fetch -p first.

You can also run the same command for branches on the git server

git branch -r --merged

origin/HEAD --> master
origin/the-everlasting-story
origin/that-guy-that-never-deletes-the-branch

Since we know which branches are already merged, we can prune them up easily. For this I created two script to automatically do this:

git branch --merged | grep -v "master" | parallel -I{} git branch -d {}
git branch -r --merged | grep -v "master" | sed -e "s/origin\\///" \
    | parallel -I{} git push origin :{}

Let’s break the second one up: