Installing Git - cogeorg/teaching GitHub Wiki

Installing Git is relatively straightforward and can be done with installers. If you run into any issues, or prefer to install Git using a different method as outlined here, see Atlassian's website, here

MacOS

We're going to use Homebrew a super helpful package manager to install Git. To check if you already have a version of Homebrew installed, type the following into your terminal

$ brew which 

If you see a version of homebrew installed, you can skip the next step. If you do not however see a version of brew installed, paste the following line of code into your terminal

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once you hit enter, you'll be notified of what the script will install. Once the process is complete, if you check the version of brew installed, using the line of code from earlier, you should now see the latest version of Homebrew. If you have any issues, refer to the Homebrew website.

Now that Homebrew is installed, to install git we're simply going to run

$ brew install git

Once executed, you will be able to see the version of git installed, using

$ git --version

Lastly, you're going to want to change your git username and git email address. This will be the name and contact details that get assigned to every change to make to a code base. To change these, simply run the following code, and use your name and email

$ git config --global user.name "Tim Apple"
$ git config --global user.email "[email protected]"

This sets your username globally for every repository on your PC. If you however want a specific username for a specific repo, simply navigate to the directory associated with the repository in your terminal and type

$ git config user.name "Tim Cook"

Linux

Git can be installed easily using APT (Advanced Package Tool). From your shell, type

$ sudo apt-get update
$ sudo apt-get install git

Once executed, you will be able to see the version of git installed, using

$ git --version

Lastly, you're going to want to change your git username and git email address. This will be the name and contact details that get assigned to every change to make to a code base. To change these, simply run the following code, and use your name and email

$ git config --global user.name "Tim Apple"
$ git config --global user.email "[email protected]"

This sets your username globally for every repository on your PC. If you however want a specific username for a specific repo, simply navigate to the directory associated with the repository in your shell and type

$ git config user.name "Tim Cook"

Windows

For PCs running Windows, the easiest way to install git is simply via the Windows installer.

Once installed, you're going to want to change your git username and git email address. This will be the name and contact details that get assigned to every change to make to a code base. To change these, simply go to your command prompt and run the following code, and use your name and email

$ git config --global user.name "Tim Apple"
$ git config --global user.email "[email protected]"