Tech 18. Aug. 2015

Get rid of git branches

Recently I had to hop into a existing project and tried to manage dev, test, stage and production version in git and JIRA, which is no big deal at all. Because of the longer history we had about 100 feature branches within the git, which made it a little unconvinient to ge an overview. So I tagged all historical feature branches and removed them from origin. And because of the large amout I found some command line tricks to to that as batch:

git branch -r | awk -F/ '/\/PREFIX/{print $2}' | xargs -I {} git tag archive/{} origin/{}
git branch -r | awk -F/ '/\/PREFIX/{print $2}' | xargs -I {} git push origin :{}
git fetch -p

Recently I had to hop into a existing project and tried to manage dev, test, stage and production version in git and JIRA, which is no big deal at all. Because of the longer history we had about 100 feature branches within the git, which made it a little unconvinient to ge an overview. So I tagged all historical feature branches and removed them from origin. And because of the large amout I found some command line tricks to to that as batch:

git branch -r | awk -F/ '/\/PREFIX/{print $2}' | xargs -I {} git tag archive/{} origin/{}
git branch -r | awk -F/ '/\/PREFIX/{print $2}' | xargs -I {} git push origin :{}
git fetch -p