Skip to main content

Git for Authors

Chapter 2 All By Yourself

git is at its best when people collaborate, but it can still be valuable to an individual, and you may gain collaborators or contributors in the later stages of a project. We can understand some basic concepts by considering first the simple situation of a single, solo contributor.
You will not fully appreciate all of our Principles on a first reading, but if you come back to review them, they may be more useful on each reading. Here is one such.
You may be very comfortable with organizing your writing as a collection of files, perhaps further organized in a series of directories or folders, perhaps even nested several levels deep. git works on, and manipulates, your files for you, which can be disconcerting at some point. The objects that git stores and tracks are collections of changes to your files. One such collection might make several small changes to several different files (perhaps you renamed a character throughout your novel), or the change may be to add a new file (an entire new chapter, say). As you instruct git to move between branches, you might see your character’s name change back and forth, or you might see your new chapter entirely disappear, only to reappear later. The files in your project are the cumulative result of many changes applied in sequence, not some final state that never regresses to an earlier state. But don’t panic, git has all your changes stored away safely.
git manages changes to your files, and those changes are accumulated in files, whose state may change in ways you are not accustomed to.
If that sounds scary, realize that RAB is self-taught when it comes to git and has never lost any work. He has panicked. But he has gained valuable experience puzzling his way out of some jams (see Chapter 7). And once he ended up applying the same collection of changes twice, mysteriously getting two of everything in a chapter (see Section 8.3).
You now know, and have experience with, four of the six important concepts of working with git: committing, branching, rebasing and fast-forward merging. Only (general) merging and pull requests remains. But first, let us get social and begin collaborating with others, to realize some of the most powerful aspects of git.