Setting up Git on Your Local Machine

3/22/20235 min read

Setting up Git on Your Local Machine

In the last blog, we saw the basics of Git & GitHub. In this blog, we'll be setting up Git on your local machine. We'll be covering all the major platforms Windows, Linux, and MacOS.

Installing Git on Windows

The installation process for Windows is a bit long. Be patient and follow the instructions carefully.

  1. Browse to the official Git website: https://git-scm.com/downloads

  2. Click the download link for Windows and allow the download to complete.

  3. Once the download is complete, open the installer and follow the prompts to install Git on your system.

Read and Accept

  1. The installer will ask you for an installation location. Leave the default, unless you have reason to change it, and click Next.

select git installation

  1. A component selection screen will appear. Leave the defaults unless you have a specific need to change them and click Next.

component selection

  1. The installer will offer to create a start menu folder. Simply click Next.

Start menu folder

  1. Select a text editor you’d like to use with Git. Use the drop-down menu to select whichever text editor you prefer and click Next.

Text editor

  1. The next step allows you to choose a different name for your initial branch. The default is 'master.' Unless you're working in a team that requires a different name, leave the default option and click Next.

Initial branch name

  1. This installation step allows you to change the PATH environment. The PATH is the default set of directories included when you run a command from the command line. Leave this in the middle (recommended) selection and click Next.

Git path enviorment variable

  1. The installer now asks which SSH client you want Git to use. Git already comes with its own SSH client, so if you don't need a specific one, leave the default option and click Next.

Choose a git SSH Client

  1. The next option relates to server certificates. Most users should use the default. If you’re working in an Active Directory environment, you may need to switch to Windows Store certificates. Click Next.

Server Certificates

  1. The next selection converts line endings. It is recommended that you leave the default selection. This relates to the way data is formatted and changing this option may cause problems. Click Next.

Line endings

  1. Choose the terminal emulator you want to use. The default MinTTY is recommended, for its features. Click Next.

Terminal Emulator

  1. The installer now asks what the git pull command should do. The default option is recommended unless you specifically need to change its behavior. Click Next to continue with the installation.

Git Pull

  1. Next, you should choose which credential helper to use. Git uses credential helpers to fetch or save credentials. Leave the default option as it is the most stable one, and click Next.

Credential Helper

  1. The default options are recommended, however, this step allows you to decide which extra option you would like to enable. If you use symbolic links, which are like shortcuts for the command line, tick the box. Click Next.

Extra options

  1. Depending on the version of Git you’re installing, it may offer to install experimental features. At the time this article was written, the options to include support for pseudo controls and a built-in file system monitor were offered. Unless you are feeling adventurous, leave them unchecked and click Install.

Experimental Options

  1. Once the installation is complete, tick the boxes to view the Release Notes or Launch Git Bash, then click Finish.

Finish Installation

  1. Open Git Bash and type git --version to confirm that Git is installed and working correctly.

Git Bash

Installing Git on Linux

  1. Open a terminal window and enter the following command to install Git:
sudo apt-get install git
  1. After the installation is complete, enter the following command to verify that Git is installed:
git --version

Installing Git on MacOS

  1. Open a terminal window and enter the following command to install Homebrew, a package manager for MacOS.Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's operating system, macOS, as well as Linux.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. After Homebrew is installed, enter the following command to install Git:
brew install git
  1. After the installation is complete, enter the following command to verify that Git is installed:
git --version

Basic Git Setup

Once Git is installed on your local machine, you'll need to configure it with some basic information, such as your name and email address. Here's how to do it:

  1. Open a terminal or command prompt window and enter the following commands, replacing "Your Name" and "[email protected]" with your own name and email address:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
  1. Next, you'll need to generate an SSH key pair, which will allow you to securely connect to Git repositories without having to enter your username and password every time. To do this, enter the following command:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
  1. Follow the prompts to generate your SSH key pair. Once it's done, enter the following command to display your public key:
cat ~/.ssh/id_rsa.pub
  1. Copy your public key to your clipboard and add it to your GitHub account or any other Git hosting service you use.

You can refer to the official GitHub docs for more information.

Conclusion

This was all about installing Git on your local machine. In the upcoming blog, I'll be writing about Creating your first GitHub repo.

Thank you for reading and do let me know your thoughts in the comments!

Website | Twitter | LinkedIn | Instagram | Mail