Average rainfall 2001-2016, global tropics

Map: Average rainfall 2001-2016, global tropics

Install git for command line

Thomas Gumbricht bio photo By Thomas Gumbricht

NOTE, 1 October 2020 the label ‘master’ was replaced by ‘main’ for the default repo branch.

Introduction

This post summarises how to install the command-line tool git.

Prerequisites

This tutorial relies heavily on the Terminal command tool, if you are not acquainted with the command line, the Command line crash course (pdf) will teach you most things you need to know.

git for command-line use

Check out if you have the command line tool for git installed by opening a Terminal window and type:

$ git version

If your system does not have git installed you can install it via GitHub Desktop or download it from the git official download page.

If your version is outdated compared to the git official download page, you can instead use git itself for updating:

$ git clone https://github.com/git/git

Check and setup user name

Every git project (repository, or repo for short) is linked to a user name. If you have a dominating, or single, git user on your machine you can add a global user name to your local machine git. If you have more than one git user you can set the user name in each local repo. The local user over-rides any global user, so you can set both types in the same machine. For more information, please vist the GitHub page Setting your username in Git.

Global git user name

To check if you have a global git user name set, open a Terminal window and type:

$ git config --global user.name

If you had no global user but require one, set the git global user name with the command:

$ git config --global user.name username

Local (repository) user names

To set local (per repo) user names you have to sequentially change directory cd to each repo that requires a local user and then check/set the user name.

$ git config user.name

$ git config user.name repo-username

Check and set email

See the official GitHub page on Setting your commit email address to understand your alternatives for open or restricted email addresses.

The principles for setting your git email address is similar to setting the git user name. Here is, for example, how to check and set a global email:

$ git config -- user.email

$ git config -- user.email email@example.com

For local (per repo) setting of email you have to sequentially change directory to each local repo for which to set the email.

Password

Transferring data from your local machine to an online git account with for instance GitHub.com, you can use either HTTPS or SSH. HTTPS is safer and more widely accepted, and also the format that GitHub.com recommends. If these alternatives are totally new for you, never mind. Just go ahead and git will use HTTPS without you knowing it.

HTTPS

There are different options regarding how to set your password if you are cloning using HTTPS. If you use the GitHub Desktop app for pulling, committing and pushing staged changes, you do not need a separate git password. The same is true if you use, for example, Eclipse for cloning. In both cases your password will be stored by the app you use. You can also choose to give the password each time it is requested by git. The last option is Caching your GitHub password in Git.

SSH

SSH (means secure shell) is more cmplicated but will facilitate if you use the git command line tool (rather than GitHub Desktop and GitHub.com itself directly). All the other posts in this blog deal with using the git command line tool. Thus the next post in this series deals with git Secure Shell (SSH).

Online resources

To try git out and learn about git control on GitHub.com the youtube video Github Tutorial For Beginners is instructive.