Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash script to split multi-cookbook repo into individual git repos, retaining history, and uploads to github
#!/bin/bash
for cookbook_dir in `ls community-cookbooks`; do
if [ $cookbook_dir != 'readme.md' ]; then
REPO=chef-$cookbook_dir
git clone --no-hardlinks ./community-cookbooks/ $REPO
SAVEDIR=`pwd`
cd $REPO
git filter-branch --subdirectory-filter $cookbook_dir HEAD -- --all --prune-empty
git reset --hard
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --aggressive --prune=now
git remote rm origin
DESCRIPTION=`grep -w description metadata.rb | sed -e 's/^description[ \t]*//g'`
HOMEPAGE='http://heavywater.ca'
hub create heavywater/$REPO -d "$DESCRIPTION" -h $HOMEPAGE
git push origin master
cd $SAVEDIR
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment