Installation and setup

Author

Marie-Hélène Burle

In this section, we will learn how to install and configure Git.

Installing Git on your machine

You don’t have to install Git locally for this course if you plan on using our training cluster.

MacOS/Linux users

Install Git from the official website.

Windows users

Install Git for Windows. This will also install Git Bash, a Bash emulator.

Git is built for Unix-like systems (Linux and MacOS). In order to use Git from the command line on Windows, you need a Unix shell such as Bash. To make this very easy, Git for Windows comes with its Bash emulator.

Git in the Alliance clusters

On the Alliance clusters, Git is not only already installed, but it gets automatically loaded at each session, so you don’t have to load a module for it (as you do for most software). This is because Git is an integral part of any good workflow.

Logging in our training cluster through SSH

A username, hostname, and password will be given to you during the workshop.

Note that this temporary cluster will only be available for the duration of this course.

Open a terminal emulator

Windows users:  Install the free version of MobaXTerm and launch it.
MacOS users:   Launch Terminal.
Linux users:     Open the terminal emulator of your choice.

Access the cluster through secure shell

Windows users

Follow the first 18% of this demo.

For “Remote host”, use the hostname we gave you.
Select the box “Specify username” and provide your username.

Note that the password is entered through blind typing, meaning that you will not see anything happening as you type it. This is a Linux feature. While it is a little disturbing at first, do know that it is working. Make sure to type it slowly to avoid typos, then press the “enter” key on your keyboard.

MacOS and Linux users

In the terminal, run:

ssh <username>@<hostname>

Replace the username and hostname by their values.
For instance:

ssh user21@somecluster.c3.ca

You will be asked a question, answer “Yes”.

When prompted, type the password.

Note that the password is entered through blind typing, meaning that you will not see anything happening as you type it. This is a Linux feature. While it is a little disturbing at first, do know that it is working. Make sure to type it slowly to avoid typos, then press the “enter” key on your keyboard.

Troubleshooting

Problems logging in are almost always due to typos. If you cannot log in, retry slowly, entering your password carefully.

Using Git

We will use Git from the command line throughout this workshop. Why? There are very friendly GUIs (graphical user interfaces) software for Git, but there are many good reasons to learn how to use Git from the command line:

  • GUI software tend to be buggy,
  • they are limited to simple operations and you can’t use Git to its full potential with them,
  • when you work on a remote machine (e.g. on the Alliance clusters), using Git from the command line is so much more convenient,
  • there will be situations in your life when you will not have access to your favourite Git GUI software and you will have to use the command line, so you need to know how to use it, even if this is not what you will do in your every day workflow.

If you work on your machine

MacOS users:      Open Terminal.
Windows users:    Open Git Bash.
Linux users:    Open the terminal emulator of your choice.

If you work on our training cluster

You are already set: as mentioned above, Git is available at every session without loading any module.

Configuring Git

Before you can use Git, you need to set some basic configuration. You will do this in the terminal you just opened.

List settings

git config --list

User identity

git config --global user.name "<Your Name>"
git config --global user.email "<your@email>"

Example:

git config --global user.name "John Doe"
git config --global user.email "john.doe@gmail.com"

It is recommended to use your real name and real email address: when you will collaborate on projects, you will probably want this information to be attached to your commits rather than a weird pseudo.

Text editor

git config --global core.editor "<text-editor>"

Example for nano:

git config --global core.editor "nano"

Line ending

macOS, Linux, or WSL

git config --global core.autocrlf input

Windows

git config --global core.autocrlf true

Project-specific configuration

You can also set project-specific configurations (e.g. maybe you want to use a different email address for a certain project).

In that case, navigate to your project and run the command without the --global flag.

Example:

cd /path/to/project
git config user.email "your_other@email"