Brendan Dawes
The Art of Form and Code

Exporting Git Branches

Here's something that may be handy for some of you working with Git. At the end of a project I'll often have many branches that I made along the way to creating the final work. That's the thing I love about using Git — having this freedom to explore down a path, play around and see what may or may not transpire. When I finish a piece of work I take time to zero the desk and archive all the work including all the different branches into their own directories. This is all done really easily with this script I found on Stackoverflow:

// replace <outputDirectory> with the path to where you want to save the branches

for branch in $(git for-each-ref --format='%(refname:short)' refs/heads); 
do git archive --format zip --output <outputDirectory>/${branch}.zip $branch; 

Use this in the command line and you'll get a nice directory filled with all the different iterations / branches of your project.