Skip to content

Instantly share code, notes, and snippets.

@rickdaalhuizen90
Created April 7, 2019 11:08
Show Gist options
  • Save rickdaalhuizen90/f40cd88a884c12e0afadb450b419012b to your computer and use it in GitHub Desktop.
Save rickdaalhuizen90/f40cd88a884c12e0afadb450b419012b to your computer and use it in GitHub Desktop.
#!/bin/sh
echo "Deleting old publication"
rm -rf public
mkdir public
git worktree prune
rm -rf .git/worktrees/public/
echo "Checking out gh-pages branch into public"
git worktree add -B gh-pages public origin/gh-pages
echo "Removing existing files"
rm -rf public/*
echo "Generating site"
hugo
# commit the changes in the clone and push them back to the local gh-pages branch
cd public && git add --all && git commit -m "Publishing to gh-pages" && git push -u origin gh-pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment