There are many ways to manage and store your writing drafts. Some people prefer cloud storage services (like Dropbox) or online editors (like Google Docs), while others use desktop apps (like Microsoft Word). I am using something called GitHub.

GitHub: more than just code

I use Git and GitHub to store and access all my emails. Git is an efficient tool that you can use to track changes to a document, plus you can upload it to GitHub very quickly. It’s also quick and easy to upload your work to a second or third device.

If you’ve never heard of GitHub, it’s the world’s most popular place to host and maintain open source code. This may sound like a crazy place to post your letter, but it’s not! After all, code is just lines and lines of text, like your article, story, or dissertation.

Around 2013, GitHub started encouraging people to create repositories for all kinds of information, not just code. GitHub has never left its coding roots, but some people still use it to store posts and other non-coding projects. For example, one person used Git and GitHub to write a tutorial book, while another wrote a novel. Do a Google search and you’ll find all sorts of crazy uses for GitHub.

What is Git and GitHub?

Tabbed interface on GitHub.
Information section of the GitHub repository.

Git is an open source program created by Linus Torvalds, famous on Linux. Git tracks changes to documents and allows multiple people to work on the same document remotely. In technical terms, this is called a distributed version control system (or distributed VCS). Git cannot arbitrarily save versions of your documents at specific intervals. Instead, it saves changes to your documents only when you tell them to.

Your documents form a repository (or repo) which is just a fancy term for your project folder. For example, your Documents folder on Windows would be a repository if you used Git to manage it (but don’t).

When you save changes to your documents in Git, this is called a «commit». A commit is simply a record of the most recent changes you made to a document. Each commit is given a long string of numbers and letters as an identifier.

If you call up a past commit by its ID, you don’t see the entire project the way you do in the Word document history. You only see the most recent changes when this commit was made. However, this does not mean that the entire project was not recorded. You can remove all your entries from the project folder and still get the latest version with a few git commands. You can even go back and see what the project looked like a week ago or six months ago.

You can also include messages in every commit, which is very useful. For example, if you’re writing something but aren’t sure you want to keep it, just commit it. This section is then retained in your commit history even if you later remove it from the project.

Git works best on the command line, which is a great advantage, but also has its drawbacks. The command line is great for making commits and uploading changes. However, if you want to view the commit history, this is not ideal.

That’s why a lot of people like GitHub, a popular online service that offers a web interface to your Git repositories. On GitHub, you can easily view past commits as well as upload your commits to multiple PCs.

Together, Git and GitHub allowed me to control version history at a granular level. And my entries are easy to access on any PC that can run the Bash command line, which currently includes Windows, Mac, Linux, and Chrome OS machines.

Plain text files make things easier

Sublime text editor.
Git can help you save your writing, but it can’t make you a better writer.

Git and GitHub commit almost any type of file to write, although it works best with plain text. If you write in Microsoft Word it will work, but you won’t be able to see your past commits on the command line or on GitHub. Instead, you need to call the last commit on the command line (this is called «checkout») and then open the Word file. The Word file looks the same as it did when it was originally committed, and you can revert to the current version with another shortcut.

If you are using Scrivener this works too. Scrivener saves files as text, so it also displays past commits on GitHub and on the command line. But Scrivener also saves data that is important to the program but not to you. In each commit, you will get a lot of garbage, which will make it difficult to read.

I use plain text files because that’s all you need to put words together, especially in your first drafts.

Getting started with Git

Let’s go over the technical details of how it all works. We’ll start on PC and then move to the cloud with GitHub.

To get started, you’ll need a terminal program on macOS or Linux. If your computer is running Windows 10, you need to install Ubuntu or another Linux distribution through the Windows Subsystem for Linux (WSL), which is quite simple. You can check out our guide on how to install the Linux Bash shell on Windows 10. Or, if you’re using an older version of Windows, you can use Cygwin to get a Bash shell.

Open your terminal and navigate to the folder you want to use as your Git repository. For our purposes, let’s say we have a folder named «MyNovel» in our Documents folder. Note that there is no space between the words of our Git repository. You’ll make your life easier if you do this, because Bash doesn’t like spaces and it gets confusing to deal with.

Next, navigate to the MyNovel folder in the terminal. To do this on Windows 10, the command is:

  cd / mnt / c / Users / [YourUserName] / Documents / MyNovel 

Any WSL command that interacts with files stored in Windows must use /mnt/ . Also note that the lowercase «c» represents the drive you’re on. If your files are on the «D:/» drive, then you use /d/ .

For macOS and Linux, the command is much simpler:

  cd ~ / Documents / MyNovel 

Hence the commands are the same.

Now we need to initialize the MyNovel folder as a Git repository. This command works if you are just starting a new novel or if you already have some saved files inside.

  мерзавец 

Your folder is now a Git repository. You do not trust me? Type it in:

  ls -a 

This command asks the computer to list everything in the current folder, including hidden items. You should see something at the top called «.git» (note the dot). The hidden «.git» folder stores the version history of your document. You never need to open it, but it should be there.

First commit

Before we make our first commit, Git wants to know your name and email address. Git uses this information to determine who made the commit, and this information is included in the commit log. For practical purposes, this doesn’t matter as authors usually fly alone, but Git still requires it.

To set the email address and address, do the following:

  git config --global user.email "[Ваш электронный адрес]"

 git config --global user.name "[Ваше имя]" 

That’s all. Now let’s move on to the first commit.

Let’s assume that there are three documents in the «MyNovel» folder: «Chapter 1», «Chapter 2» and «Chapter 3». To save changes, we must tell Git to track these files. To do this, enter:

  мерзавец добавить. 

The dot tells Git to track all untracked files in the folder (i.e. the files you want to create stories for). This command also tells Git to stage any currently tracked files that have changed. This process is called commit prep files.

For our purposes, staging is not that important, but it can be useful. If you make changes to Chapter 2 and Chapter 3, but want to commit changes to Chapter 2 only, you must execute Chapter 2 as follows:

  git add Chapter2.doc 

This tells Git that you want to stage changes in Chapter 2 for commit, but not in Chapter 3.

Now it’s time for the first commit:

  Git commit -m "Это мой первый коммит". 

The «-M» is called a flag, and it tells Git that you want to commit and attach the message you see between the quotes. I like to use my commit messages to mark the word count. I also use them to record special information such as: «This commit includes an interview with the CEO of Acme Widgets.»

If I’m writing a story, I might include a message that says «This commit has a new scene where the dog is running away.» Useful messages make it easy to find your commits later.

Now that we’ve started keeping track of our documents, it’s time to push our records to the cloud using GitHub. I use GitHub as an additional backup, a reliable place to view changes to my document, and a way to access my content on multiple PCs.

Getting started with GitHub

A text form for creating a new GitHub repository.
You fill out a form to create a new GitHub repository.

First, you need to sign up for a free GitHub account (you don’t need a paid account to create private repositories). However, in a private repo, you can only collaborate with up to three people. If a team of five or more people is working on an article, you need to sign up for a Pro account ($7 per month, at the time of writing).

After you create your account, let’s make a new repo. Login to your account and go to https://github.com/new .

The first thing we need to do is name the repository. You can use the same name that you used for the folder on your computer. In the Vault Name field, enter «MyNovel».

«Description» is optional, but I love using it. You can type something like: «My fabulous new novel about a boy, a girl and their dog», etc.

Then select the «Private» radio button, but leave the «Initialize this repository with README» box unchecked. We don’t want to do this because we already have the repository on our PC. If we create a README file right now, it will complicate things.

Then click «Create Repository». Under Quick Setup — If you’ve done this before, copy the URL. It should look something like this:

  https://github.com/[Your GitHub Имя пользователя] /MyNovel.git 

Now back to the desktop and our favorite command line.

Move your desktop repository to the cloud

PC command line.
Using Git on the command line

When you first connect a repository to GitHub, you must use a few specialized commands. The first one:

  git remote добавить источник https://github.com/[Your Имя пользователя GitHub] /MyNovel.git 

This tells Git that the remote repository is the origin of «MyNovel». The URL then points Git to that remote origin. Don’t get hung up on the term «origin»; it’s just an agreement. You can call it «fluffy» if you like — origin is simpler as it’s the most common way to use Git.

When you push new changes with Git, it’s called «push». When you upload changes, this is called «pull» or «fetch». Now it’s time to push your first commit to GitHub. Here is what you do:

  git push -u мастер оригинала 

You will be prompted for your GitHub username and password. If you enter your credentials correctly, everything will load and you’re done.

If you want more security for your GitHub uploads, you can use an SSH key. This allows you to use a single password to upload your SSH key, so you don’t have to enter your full GitHub credentials every time. Also, only someone with an SSH key can upload file changes.

If you need more information about SSH keys, GitHub has detailed instructions on how to use them. You can also store your Git credentials on your computer.

This is it! Now, when you want to commit changes to your files, you can do so with these three short commands (after navigating to the «MyNovel» folder):

  мерзавец добавить. 

Translation: «Hi, Git step to commit all untracked files, as well as new changes to files you’re already tracking.»

  git commit -m "1000 слов о новом обзоре iPhone." 

Translation: «Hey Git, save these changes along with this message.»

  мастер происхождения git push 

Translation: «Hey Git, download the changes to the original GitHub version of this project from my master copy on this PC.»

Git and GitHub Bonus Tips

That’s it, but here are some additional tips to make your experience with Git and GitHub even better:

View past commits

Commit history GitHub repository interface.
You can use GitHub to view past commits.

To view past commits, go to your MyNovel GitHub repository. At the top of the main page, in the «Code <>» tab, you’ll see a section that says «[X] fixes.»

Click on it and you will see a list of all your commits. Click the commit you want and you should see your text (assuming you typed it in plain text, not Word, that is). Everything highlighted in green was new text when the commit was created; everything in red has been removed.

Use the pull command

Creating a new repository on another computer is easy. Just navigate to where you want to save the repo on the new computer, for example, cd ~/Documents . Then enter:

  git pull https://github.com/[Your Имя пользователя GitHub] /MyNovel.git 

Enter your credentials if prompted, and in a few seconds you’ll be ready to go. Now make your new changes and push them back to GitHub via git push origin master . When you get back to the PC you normally work on, just open a command prompt, navigate to your project folder and type git pull. New changes will be uploaded, and just like that, your writing project is up to date across all your devices.

Don’t cross the streams

In most cases, writing is not a team effort and only involves one person. Because of this, this article uses Git in a way that will not work for a multi-person project. In particular, we made changes directly to the main version of our novel instead of creating so-called «branches». A branch is a practical version of a novel where you can make changes without affecting the original master. It’s like two different copies of your novel that exist in parallel, and neither affects the other. If you like the practice branch changes, you can merge them into the main version (or master branch). If you don’t want to do that, that’s fine too. Just throw away the practice branch.

Branches are very powerful and using them will be a basic workflow with multiple authors on the same project. In my opinion, solo authors don’t really need to use branches unless you’re making various changes to the master branch at the same time on multiple PCs.

For example, you must complete your work on the desktop, commit, and then push the changes to GitHub. Then go to the laptop and make any new changes before making any changes. If you don’t, you may end up with what Git calls «conflicts». That’s when Git says, «Hey, there are changes in GitHub and on this machine that don’t match. Help me understand this.

Conflict exit sorting can be painful, so it’s best to avoid it whenever possible.

Once you get started with Git, you can learn a lot of things, such as branching, the difference between checkout and checkout, GitHub pull requests, and dealing with the dreaded conflict.

Git may seem complicated for beginners, but once you get the hang of it, it’s a powerful tool that you can use to manage and store your records.

Похожие записи