Skip to content

Instantly share code, notes, and snippets.

@davegurnell
Created November 11, 2014 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davegurnell/20c1440cb9352d225ae0 to your computer and use it in GitHub Desktop.
Save davegurnell/20c1440cb9352d225ae0 to your computer and use it in GitHub Desktop.
Shell script: publish examples and solutions to github without their histories
#!/usr/bin/env bash
git checkout master
git branch -D nohistory
for branch in `git branch | cut -c2-`
do
echo "========== $branch =========="
git checkout $branch
git branch -D nohistory
git checkout --orphan nohistory
git commit -m 'Initial commit'
git push github ":$branch"
git push --force github "nohistory:$branch"
done
git checkout master
git branch -D nohistory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment