Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Post-commit hook to push to gh-pages. Also pushes master to origin. Intended for use in a gitflow worflow, in other cases you might not want ot push master to origin.
cur_branch=$(git rev-parse --abbrev-ref HEAD)
# only run if commit is to master
if [ "$cur_branch" == "$push_branch" ]; then
if [ "$(git status -uno --porcelain)" ]; then
echo "uncommitted changes, can't push";
git push origin master
# recreate gh-pages, checkout, collect sanitized info, remove sensitive info, commit, push, change back to develop
git branch -f gh-pages &&
git checkout gh-pages && node utils/collectjson.js &&
rm students/*.json && git add utils/allstudents.js &&
git commit -a -m "sanitize for gh-pages
after $(git log -1 --pretty=%h): $(git log -1 --pretty=%B)" &&
git push -f origin gh-pages --quiet &&
git checkout develop --quiet && git merge master --quiet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.