The contents of this tutorial is geared toward downloading and installing git the version control system on:

Click one of the above links to be taken to the appropriate installation section. Afterwards, please make sure to look at the configure git section of the tutorial.

Download and Installation of git

Before downloading or installing any software, it may help to have a bit of a background as to what you are obtaining. Thus, let’s briefly look at “What is git?”

git is:

  • a version control system for source code
    • provides an abridged history of source code changes
    • allows for source code changes to be easily viewed and reverted to
    • so try out new ideas without worrying about breaking something!
  • a distributed versioning platform so that everyone has a backup of code
    • collaborate with others without waiting for their component to be finished
  • an open source (e.g. free) project that is cross platform (macOS, Windows, and Linux)

Windows

Unfortunately, unlike macOS and Linux, Windows does not currently have native support for git. There are three different options for obtaining git on Windows:

  1. Git Bash,
  2. GitHub Desktop, and
  3. Shell emulators

The focus of this tutorial will fall primarily on the first option with more advanced users being recommended to pursue a shell emulator, specifically WSL.

The reason why I’m opting for the first option of Git Bash is because the application is easily detected by RStudio and plays relatively nicely with it. There are limitations with respect to the amount of bash commands available though.

The following link will automatically start the download for the latest version of Git Bash for Windows: https://git-scm.com/download/win

During the installation, there will be a section called “Adjusting your PATH environment”. On this page, make sure you select the option

“Use Git from the Windows Command Prompt”

This places the git.exe on your system’s PATH variable, which allows RStudio to easily detect it. Consult the following screenshot if in doubt:

Git Adjust Path Variable

Once the installer finishes, open the Start Menu by pressing the [Windows Key] and type Git Bash. Then, please proceed to the configuration of git section.

macOS

The availability of git on macOS occurs after installing the XCode command line tools.

To do so, open up Terminal and type:

xcode-select --install

This will yield the following prompt, which you should select install from:

XCode CLI Select Prompt

Once the installer finishes, please proceed to the configuration of git section.

Linux

Official Instructions: https://git-scm.com/download/linux

Ubuntu / Debian

sudo apt-get install git

Fedora / CentOS / RedHat

sudo yum install git # CentOS, RedHat, <= Fedora 21  
sudo dnf install git # >= Fedora 22  

openSUSE

sudo zypper install git

Configure git

Introduce Yourself

To register the who component, git must be told your name and your email.

# Specify the name and email address to be associated with your changes
git config --global user.name "FirstName LastName"
git config --global user.email "email@example.com"

In my case it would be:

git config --global user.name "James Balamuta"
git config --global user.email "balamut2@illinois.edu"

git Customizations

git offers a variety of ways to customize the configuration.

By default, the following options have been set by git; however, if you find them problematic you can change them:

# Specify the editor to write commit and tag messages (e.g. nano, vim)
git config --global core.editor vi

# Colored terminal text (change to false if colorblind)
git config --global color.ui true

Other introductory options can be found here: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration

Known Errors

Did you forget to introduce yourself?

If during your first commit, you received:

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

You forgot to introduce yourself to git! So, go on… Introduce yourself!