Skip to main content

The PreTeXt Guide

Appendix H Revision Control: git

Authoring a textbook without revision control is like driving without a seat belt. Sooner or later, you will wish you had used it. git is a popular program for revision control for software projects, and works quite well with PreTeXt, though not perfectly. Notes here are designed to help. For more on git itself, in the context of authoring a book, see Git for Authors
, by Robert Beezer and David Farmer at

Word Wrap.

git is designed for code, where a newline often expresses the end of a statement. In PreTeXt, it might make sense to author an entire (long) paragraph without any newlines. If so, a line-oriented file diff is not so useful. Fortunately, git has a flag, --word-diff, which does an excellent job of displaying small edits precisely.

Messages for Commits and Merges.

When you make a commit or merge, you can supply a message at the command line with the -m argument. Otherwise you get thrown into an editor, with the default being vi, which can be hard to get out of if you have not used it before. Better, as Joe Fields suggests, is to tell git which editor you want to use. To set pico as the default editor, the one-time command-line incantation would be:
git config  --global core.editor "pico"
You can also directly edit the configuration file at ~/.gitconfig. More suggestions can be found on this thread
on StackOverflow at