Skip to content

Instantly share code, notes, and snippets.

@jlem
Last active August 29, 2015 14:19
Show Gist options
  • Save jlem/81a823064e5044106021 to your computer and use it in GitHub Desktop.
Save jlem/81a823064e5044106021 to your computer and use it in GitHub Desktop.
Exporting contents of git branches into separate folders
#!bin/bash
folder=$1
if [ -z $1 ]
then
echo 'Please provide the root destination of the export:'
read folder
fi
git fetch --all
for branch in `git branch | awk -F ' \+' '! /\(no branch\)/ {print $2}'`; do
echo 'Building folder for $branch'
git checkout $branch
mkdir $folder/$branch
git archive HEAD | tar -xC $folder/$branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment