-
-
Save belzecue/83dccee1acd7585c9fee478d558f690f to your computer and use it in GitHub Desktop.
Export each Git branch as a separate folder
This file contains 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
previous_pwd=$PWD | |
cd $(dirname $0) | |
PROJECT="$HOME/Desktop/project" | |
EXPORT_DIR="$HOME/Desktop/export" | |
rm -rf $EXPORT_DIR | |
mkdir -p $EXPORT_DIR | |
rm -rf tmp | |
mkdir tmp | |
cd tmp | |
git clone $PROJECT . | |
branches=($(git branch -a | grep remotes | grep -v HEAD | grep -v master)) | |
for branch in $branches; do | |
local name=${branch/remotes\/origin\//} | |
git checkout origin/$name | |
cp -R ./ $EXPORT_DIR/$name | |
done | |
cd .. | |
rm -rf tmp | |
# back to where we were | |
cd $previous_pwd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment