Your writing a book and you expect to spend about a year on the project. To set up your folders, you make a directory called "mybook" and subfolders called "research" and "thebook." In "thebook" folder you intend to have a file for each chapter of the book, "chapter1.doc" for example.
The way you write from draft to finished chapter, you tend to change a chapter a lot, sometimes cutting out whole paragraphs, or moving sentences to different spots in the chapter. In the past, you've deleted entire sections, and some times have regretted it, because you would have liked to reuse the section some where else in the text, and other times you like the way you worded a sentence, but lost it when you made changes.
With Git version control, you can keep all your history of changes through out your project, and not worry about losing anything. You can also make a duplicate copy of your book on another computer, and keep your book history up to date while your working. This is the beauty and benefit of version control.
We've installed Git version control on Windows in the last post. Let's at least get you started on using Git in this post.
Let's start tracking. You should have Git Bash icon on your desktop. Click it and up pops a linux command window. Don't panic. This is like the Windows command window, only it runs Linux. There is a neat little GUI that will make the command window go away. Type "git gui" to open it.
Git Gui will ask if you want to create a new repository. "Click Create New Repository," a new window will open. Browse to the folder where you want to track all your changes, i.e. "mybook," select it and click "Ok" and "Create." Your Git Gui will open. There is nothing shown in the gui, because you have blank folders.
Open your favorite editor, type in some text and save it as, chapter1. txt or doc in the sub folder "thebook." Click "Rescan" in your gui, and wahlah!, git has said you added a chapter1 file in "thebook." Click on the file, and you'll see the text you just typed. Go back to your editor, add some more text, save it, click "Rescan" in your Git gui and your changed text will show up. Git tracks every change you make to your files and folders.
The file is not yet saved in your git repository though, let's do that. Git has a two stage process to make sure you commit your changes to the git history. First you have to stage the file, and then commit it. In the upper menu, click "Commit->Stage to Commit" and the file will move to the green staged area in the gui ready for committing. If you click on the file some additional information has been added to get ready to commit.
Before you can commit the changed file to the repository for tracking, you need to put a message in the "Commit Message" window, as a hint to what was saved on this commit to the repository so when you view the history later you'll know what changes are stored in that particular commit.
Good, click, "Commit." Everything disappeared, what happen? You saved everything in the repository. There are no new changes in the entire file system, so your gui is "clean."
Make some changes to the chapter1 file, and let's add a "chap1research" file to the research sub directory. Click "Rescan." Notice in the Git Gui the "chapter1 file has more text, and there is another file added located in the research sub directory.
Click "Commit->Stage to Commit" and the two files move to "Staged Changes" ready for saving. Put a commit message in the message window, and click "Commit." Everything goes away, you have a clean working directory.
Now, let's go back in history and take a look at "Chapter1" before the last change. Go to the upper menu in the Git Gui and click, "Repository->Visualize Masters History." This opens gitk.
Gitk tracks the entire history of your project. Click on your first commit message in the upper left window. Now move to the lower right window, and you'll see "thebook/" the book directory. Click on it and you'll see the file "chapter1.txt" Click on the "chapter1 file and you'll see the text in the lower left window that existed before the second commit change to the file.
Let's see the second commit. In the upper left window, click on the "master" and in the lower right window, the research directory will now appear. Click on "thebook" directory again and the "chapter1" file and you'll see your chapter1 changes on the second commit.
Git is loaded with functionality. I'll leave you to explore some of the other menu choices in these Gui's. Git is used by any one that builds projects, like software developers and writers, to keep track of changes in their files. There are currently three very good books on Git if you'd like to get really proficient.