Skip to content

Instantly share code, notes, and snippets.

@belzecue
Forked from pavanpodila/create_export_pack.sh
Created April 20, 2024 11:41
Show Gist options
  • Save belzecue/83dccee1acd7585c9fee478d558f690f to your computer and use it in GitHub Desktop.
Save belzecue/83dccee1acd7585c9fee478d558f690f to your computer and use it in GitHub Desktop.
Export each Git branch as a separate folder
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