git-workshop

Installation of Git including Bash

Is this section core or elective? Expected time to completion
core before second meeting

This chapter is an installation guide for git, including bash.

Goal

After completing this chapter, you should:

Moreover, at the end of this chapter, we will briefly introduce the procedure of how to submit your solutions to the exercises that you will be asked to do during the following git chapters.

Installation

We recommend installing the latest release of Git for Windows from the official git homepage. In case you already have git installed, we recommmend to uninstall and re-install it with the settings given here. Download the latest 64-bit version of Git for Windows Setup, Git for Mac, or Git for Linux and run the downloaded executable.

Remove the Only show new options check box. When executing the installation, we recommend chosing the following options.

Components

We recommend only installing Git Bash as we do not plan to use the Git GUI offered with this executable.

Note that there are many different Git GUIs available for different operating systems which may be convenient to use. However, in order to learn about the core git commands, it is preferable to get used to Git Bash first. This has the added advantage of supplying you with knowledge transferrable to other OSes.

git default editor

The default editor is automatically opened e.g. when git offers you to edit the default commit message.

We strongly recommend that you choose Nano and learn to write proper commit messages with a title and body rather than restricting yourself to whatever you can write on the command line out of fear of ending up stuck in Vim, unable to quit. Unless you already know Vim and are comfortable with it, choose a different editor.

Vim is a very powerful tool and we do recommend learning to use it in the long term. In the short term, please learn some basic vim commands (how to quit, at the very least). It is one of the editors which is available on almost all UX operating systems.

Default initial branch name

When a new git repository is initialized, the main branch is by default named master. However, you have the possibility to change the default name of the initial branch in a new repository. It is not recommended changing the default setting, unless you know what you are doing.

Adjusting your PATH variable

The PATH variable is an environment variable which specifies a set of directories where executable programs are located. This is the set of locations where command-line interfaces (e.g., the Windows Command Prompt or a Powershell terminal) will search for executables when you issue a command without specifying its exact location. (For more details, see the corresponding Wikipedia page).

We suggest adding only the git executable to your operating system’s PATH variable (i.e. the recommended option), which allows you to run git commands through any command-line interface on your system (and not only from within the Git Bash). If you forgot to do this during the installation, you can add the path as follows: Open View advanced system settings -> Environment Variables. In either the User variables for XXX or the System variables, select the entry for Path and click on Edit... This will allow you to add a line containing the path to the git executable.

Library for secure HTTPS connection

Use the OpenSSL library to secure the HTTPS connections established with GIT.

Handling line endings

It is important to know that Windows uses different line endings in text based files than *nix OSes (CR instead of CR-LF), see the Wikipedia entry on newline. Since we are working on a Windows system we recommend to checkout the files Windows-style and commit Unix-style line endings. This helps to seamlessly pass text files between operating systems: you receive a nice representation of text files in Windows but preserve their Unix-consistent line endings upon committing.

Terminal emulator

We recommend to chose the Unix-like MinTTY terminal.

Default behaviour of git pull

The default behaviour to the git pull command should be set to fast-forward or merge. We shall cover git pull and merge strategies in the chapters to come. For additional information, see here:

Credential manager

In case you want to use a credential manager, we recommend to chose the cross-plattform version offered during the installation process.

Extra and experimental options

System caching increases the performance in git, symbolic links are optional. Do not enable any experimental support.

With the above settings, the installation process should run smoothly, and get you set up for the subsequent chapters in a breeze.

Further reading