Installing and Setting Up Git

No one learns to ride a bicycle by just reading about bicycles. Similarly, you can't learn to use git and understand it by only reading about it. You have to use it and experiment with it, too. Thus we begin by discussing how to set up git on various platforms.

Installing on Andrew Linux

Fortunately, git is preinstalled on Andrew Linux. The version (1.8.3.1 as of Fall 2017) is a bit old, but it's recent enough for most purposes.

Installing on Linux

Many Linux distributions come with git preinstalled. You can check this by running git --version in the terminal and seeing if a version number is printed. If git is not installed, you can usually install git from your package manager. This will probably involve one of

If you don't have a package manager, then you probably have the ability to figure out how to install git on your own.

Installing on Mac OS X

Your Mac should come with git preinstalled. Preinstalled Mac command line tools can often be out of date, so you can use homebrew to install a newer version (but the preinstalled version is fine for this course).

Installing on Windows

Git was explicitly designed for Unix-like (POSIX) environments and is incompatible with native Windows environments. In order to run git on Windows, you need an artificial POSIX layer and basic UNIX tools like sed and grep. Git for Windows provides git and these tools in a convenient package. You should install this.

Note that if you choose the default options during installation, you will need to launch "Git Bash" in order to use git instead of Command Prompt or Powershell. Making a shortcut for Git Bash would be a good idea.

Basic Setup (all platforms)

Every git commit has the author and the author's email address attached. You need to tell git who you are and what your email address is so that it can automatically tag your commits with them. To do so, enter the following into a terminal:

git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL ADDRESS"
git config --global color.ui true

Because of differences in the way Windows and Unix-like OSes handle line-endings, if you are on Windows you should enter

git config --global core.autocrlf true

and on Mac and Linux, you should enter

git config --global core.autocrlf false

← Back to home