You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
git worktree add /tmp/book gh-pages
mdbook build
rm -rf /tmp/book/*# this won't delete the .git directory
cp -rp book/* /tmp/book/
cd /tmp/book
git add -A
git commit -m 'deploy new book'
git push origin gh-pages
cd -
Or put this into a Makefile rule:
.PHONY: deploy
deploy: book
@echo "====> deploying to github"
git worktree add /tmp/book gh-pages
mdbook build
rm -rf /tmp/book/*
cp -rp book/* /tmp/book/
cd /tmp/book && \
git add -A && \
git commit -m "deployed on $(shell date) by ${USER}" && \
git push origin gh-pages
You may want to delete history on the gh-pages branch to avoid increasing the size of the repository significantly.
To do that, the following command can be run before calling git add:
git update-ref -d refs/heads/gh-pages
This will also require adding the --force flag to git push.