Skip to content

Instantly share code, notes, and snippets.

@archaeogeek
Last active August 29, 2015 14:05
Show Gist options
  • Save archaeogeek/0c055761343996acd432 to your computer and use it in GitHub Desktop.
Save archaeogeek/0c055761343996acd432 to your computer and use it in GitHub Desktop.
Pre-push code for automatically generating GitBook static html, pushing the markdown to a master branch and the generated html to a gh-pages branch on github. Save as a pre-push hook (git 1.8 or above) for the master branch. Set the _book folder and contents to be ignored in the master branch to avoid duplication.
#!/bin/sh
gitbook build /path/to/markdown --output=/path/to/markdown/_book
cd /path/to/markdown/_book
git init
git commit --allow-empty -m 'update book'
git checkout -b gh-pages
touch .nojekyll
git add .
git commit -am "update book"
git push git@github.com:user/repo gh-pages --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment