My Git Book Writing Blog

Using Git for the Book (Part 4): Time Traveler Clone

One of the things that I do with the MS Word manuscript files is compare versions. However, in Git your working directory represents only one commit. How do I compare two commits at the same time? (I can get a rough comparison with git diff, but for this post, how can I use MS Word’s comparison tool, which wants an old version and a new version of a file?)

Clearly I need two copies of the MS Word file that I want to compare. I looked briefly at git diff, which somehow compares two files. The code for git diff is in C, with plenty of Git internals. I didn’t go down that path, and in the end, I did a possibly low-tech solution:

1
$ git clone gitbook gitbook-timetravel

This command created a clone of my repository named gitbook-timetravel. Since it’s a clone, I can access any commit. And because its origin remote is my active repo, I can update it at any time by doing a git pull.

With these two directories (gitbook and gitbook-timetravel), I can now compare files using Word. I use the gitbook-timetravel for the older version, leaving gitbook at the current revision.

A solution to a technical problem doesn’t have to be technical! Thanks for reading, everyone!