Last active
August 29, 2015 14:19
-
-
Save jlem/81a823064e5044106021 to your computer and use it in GitHub Desktop.
Exporting contents of git branches into separate folders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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