Advertising

How To: Use Git to Version Your Writing

Advertising
How To: Use Git to Version Your Writing

If you are a writer you may have ran into this problem. You are writing like mad, moving things, changing the way something flows. As you are getting into it, you realize.

Hey! This isn’t what I want to say at all! I need to go back.

You feverishly tap CTRL + z (or Command + z for you Mac aficionados) and come to find that your favorite “no frills” text editor has lost your undo history or you aren’t quite sure where you want to go back to.

Good for more than just development

Git is a piece of software that allows the user to control the versions of files in a directory. It allows the user to ‘commit’ a snapshot of any directory to a ‘repository’ that tracks all of the changes between versions of the files.

Git is awesome for development. But, what I have found is that it is awesome for writing as well.

Git allows me to commit my writing every so often so I can get back to where I want to be. It also allows me to ‘branch’ my writing so I can separate it from everything else.

Let’s take a look at how you can use git to control your writing versions.

Installation, Initialization, and committing

I will be covering Windows and Mac here. For you Linux geeks; you should already know how to use git!

Advertising

To install git do the following:

    For Windows:

    Go to git-scm.com, click on the Windows link to the right and download the latest version. Install via the executable and choose the most standard settings. When you get to the Adjusting your PATH environment screen, select the first option, Use Git Bash only and hit next. When at the Configuring the line ending conversions, select the third option, Checkout as-is, commit as-is and hit next. After the install completes click “Finish”.

    For Mac:

    Go to git-scm.com, click on the Mac OS X link to the right and then click the latest .DMG file in the list to download. Launch the DMG from your Downloads directory and double-click the git PKG. Follow the on-screen instructions and enter your user credentials. Close the installer when it is complete.

    OK, now that you have git installed we are going to get geeky and use a terminal in both Windows and Mac.

    To get to the git terminal in Windows go to the Start button and search for ‘git’. Click on ‘Git Bash’ to get to your git command line interface.

    For Mac just open a terminal by going to Applications > Utilities > Terminal.

    Advertising

    Here is where the fun begins. Let’s say you have a folder where you store a bunch of writing. For me that is in my Dropbox/writing folder. If I want to start tracking that directory I can change to that directory via command line then initialize a git repository.

    This will be close to the same on both platforms. To change to a certain directory use the command:

    cd [path-to-your-writing-directory]

    Of course fill in your own directory. My command looks like this in Windows:

      The backslash after ‘My’ is used to tell the terminal that the space after the word ‘My’ is there. You can autocomplete your paths by starting to type a directory and then hitting the ‘Tab’ key.

      And this on my Mac:

        Once you are at the directory you have all of your writing in you can issue the command git init which initializes a blank “repository” for your directory. This puts a .git directory that is initialized. Once your repository is initialized you can add the files to the repository by typing

        Advertising

        git add .

        or

        git add [some-name-of-a-file]

        to add only one file.

        After that you can commit your files to the repository by typing

        git commit -m “This is my first commit (or some other message)”

        ‘-m’ is used to tell git that you want to put a message with your commit. Now you have made your first commit to your new git repository! Congrats, you geek.

        More on committing and branching

        OK, I know that was a little technical, but you are over the hump now. If you want to learn more about git though in your free time, check out Pro Git. It’s free and it is the best tutorial on the inner workings of git.

        Advertising

        So, what committing does is take a “snapshot” of the directory structure or whatever files you told your git repository to watch. If you make a change to a sentence in one of the files that your repository is watching after you just committed and type ‘git status’ you will be presented with the changes that have been made to the watched files. This lets you know that you have “uncommitted” changes to your watched files. You can then easily commit them by issuing the git commit command.

        Another neat feature of git is branching. Branching is the idea of making a totally separate branch of your repository. You can create a new branch by typing:

        git checkout -b this-is-a-new-branch

        You can then make changes to your tracked files totally separate from your “master” branch. This allows you to take different paths with your writing without screwing up something else that was committed.

        To switch back to your “master” branch, type:

        git checkout master

        Also, remember to commit any changes before creating and changing to new branches. If you don’t you may run into issues down the line where some changes get dropped.

        More to come

        Let us know if you think that this is helpful or want to learn more about using git to track files leave some messages in the comments.

        Advertising

        Git is a super application; one that I use everyday. I can’t praise it enough. But, remember, it doesn’t have to be just used by geeks and hackers, writers can use it to keep track of their work and to feel free to explore other writing avenues without losing valuable work they have already created.

        More by this author

        CM Smith

        A technologist and writer who shares advice on personal productivity, creativity and how to use technology to get things done.

        Protecting Your Online Life With Secure Passwords Thanksgiving: It’s About The Simple Things How to Beat Procrastination: 29 Simple Tweaks to Make 5 Project Management Tools to Get Your Team on Track To Automate or not to Automate Your Personal Productivity System

        Trending in Technology

        1 How to Make Private Browsing on Safari Truly Private 2 20 Must-Have iPad Apps /iPhone Apps That You May Be Missing 3 Finally, 20 Productivity Apps That Will Ensure Efficiency 4 8 Useful Apps Every Learner Should Not Miss 5 Protecting Your Online Life With Secure Passwords

        Read Next

        Advertising
        Advertising

        Last Updated on November 25, 2021

        How to Make Private Browsing on Safari Truly Private

        Advertising
        How to Make Private Browsing on Safari Truly Private

        There comes a time when we may be searching online and don’t want the browser to remember our footsteps. The reasons don’t always have to be what we obviously think of as the main reason; for example, sometimes, you may not want Safari to remember your passwords or prompt you to enter your password when surfing the web.

        Whatever the reason, we may think that we are totally in the clear with Private Browsing on Safari and the other browsers on a Mac. However, a quick Terminal command can bring up every website you’ve visited. How do you do this? Also, how do you clear your tracks for good? We will provide both answers and more today.

          What Does Private Browsing Do?

          When activated, Private Browsing on Safari prevents your browsing history from being kept in the history tab of the application. Along with this, it doesn’t autofill information that you have saved in the browser. In this mode, you essentially become incognito and any references of previous use is essentially hidden when you are in private mode.

          For example: if you are on Facebook or filling out a form and some information or your login is already filled in in the spaces provided, this is called autofill. It’s activated by simply clicking Safari next to the Apple symbol in the menubar and selecting Private Browsing, then clicking “OK” to the prompt.

          Advertising

          The reasons behind private mode differ for each individual. While we won’t go into all of those reasons, one thing that is  important to remember is that private browsing doesn’t forget the websites you visit. As we will see later on, Macs keep a second copy of the websites you visit in either mode. If you are in frantic mode looking for a solution to this, look no further.

          The Terminal Archive

          While Safari does a good job of keeping your search history out of prying eyes in the history tab, there is a less-than-obvious way to view a full list of visited websites on Mac. This is done in Terminal; the command-line emulator that allows you to make changes to your Mac.

          Terminal is located in the Utilities folder on your Mac. Once activated, simply add the command:

          dscacheutil -cachedump -entries Host

          Advertising

          Once you hit “enter”, a list of the visited sites appear. Showing only the domains, the sites appear in a format of:

          Key: h_name :(website domain)ipv4 :1

          However, there’s no need to fear—there is a way you can clear this information from Terminal with a command that’s just as simple.

          Clearing Your Tracks

          Just as simply as you were able to enter the command to view the websites, you can clear the cache that Terminal showed you with the comamnd:

          Advertising

          dscacheutil -flushcache

          As the command denotes, this literally “flushes” the domains from Terminal. This does not prevent the record from continuing to be recorded for future sites, however, so if that’s an issue for you, repeat this process regularly.

          Other Browsers and Private Browsing

          Other browsers have this form of privacy mode for their service. They promise many of the same things as Safari, but they do not have the same Terminal issue due to how this command only presents websites visited on Safari (the browser Macs come shipped with).

          If you use Firefox, you’ll notice that its private mode is also known as Private Browsing. Chrome calls private mode Incognito, while Internet Explorer refers to it as InPrivate Browsing. Opera is the newest to the scene, denoting it as Private Tab. Safari is the oldest well-known browser with this feature.

          Advertising

          As you can see, despite Private Browsing not being 100% private, Terminal allows for your browser to be. In what ways has Terminal helped your life or allowed you to become more productive? Let us know in the comments below.

          Featured photo credit: Benjamin Dada via unsplash.com

          Read Next