Git: Setup

What is version control? And how do I set up Git?

What is version control? Put simply, version control lets you easily save, review, reinstate, branch off side projects and in general work more effectively with your coding project. If used correctly it can have a massively beneficial effect on your workflow.

The version control software we will use is called Git.

Before getting started with Git, you will need to set up your config file. This will allow Git to store information about who has made change to files in a git repository. We can alter a variable held in this file using the git config command.

There are two variables we want to alter: "user.email" and "user.name". Assuming you are on your own computer, you will want to set these settings globally using the --global flag. You can also set these values on a per-repository basis once you have initialised a git repository (in the next article). For most people, a global option is best.

                    $ git config --global user.name "Malcolm Reynolds"
                    $ git config --global user.email "mal@serenity.com"
                    $

If you would like to change the default editor (VI) that git will use for writing commit messages then you can do that by changing the value of "code.editor". For example, here I am changing the editor to use sublime.

                    $ git config --global core.editor "subl -n -w"
                    $

Take a look at this GitHub article for more information on changing the default text editor.