Introduction
Joint or shared (coding) projects benefit largely from a repository service that keeps track of versions and changes. Git, initially developed by Linus Torvalds for creating Linux OS, is today the most widely used distributed version control system. This post summarises how to install the command-line tool git for Git control.
There are two ways two securely connect from a local (machine) Git and an online GitHub repository: HTTPS or SSH. At time of updating this post (February 2020) the HTTPS solution is recommended on the GitHub help page Set up Git. Only HTTPS is covered in this post.
Setup 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 repository is linked to a user name. If you only have one Git user 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 repository (folder containing hidden .git system). For more information, here is the link to the GitHub page Setting your username in Git.
Global Git user names
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 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
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 as explained on the official help pages of GitHub.
Try it out
To try git out and learn about Git control on GitHub.com the youtube video Github Tutorial For Beginners is instructive.