I think this might be preferable to current behavior of initializing an empty local repo and force pushing it onto github. The flow would be
- if gh-pages branch exists
- stash local changes
- pull from remote
- apply stashed changes
- push
This would preserve gh-pages commit history. It would also prevent forcible overwrite of other files in the gh-pages branch that are not used by gitbook, such as supplementary data files, or a CNAME file (which is necessary for custom domain name using github pages). Such files currently get forcibly overwritten in the current behavior, even if added to .gitignore file.