It is best to write your book in a text format (that Git can easily stored), and generate the target format from those sources.
The article "Publishing eBooks with AsciiDoc" illustrates that process, using asciidoc
format (text) to generate epub.
It uses the a2x
toolchain manager for the generation:
a2x -fepub -dbook minimal-book.txt