Setting up Git on Your Local Machine
Tags: git, tutorial
Published: 2023-03-18 18:30:00

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
Installation process for windows is a bit long. Be patitent 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.
![Download Git For Windows](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ubahvjph7vkpv95cdeuo.png)

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

![Read and Accept](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3g5m03l47i2wrs4vvylx.png)
4.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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3szufx6agl53suocvusr.png)

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

![component selection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7z6xeh3pd0qy1qy31rrq.png)

6.The installer will offer to create a start menu folder. Simply click **Next**.
![Start menu folder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ieoqi7jvffmu79vg6p8q.png)

7.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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tmmn01k31a9egh8deb3.png)

8.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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/naizu32cdtr3lg0acmez.jpg)
9.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 on the middle (recommended) selection and click **Next**.

![Git path enviorment variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5drfefaqy88zsmgnn0k0.png)
10.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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/502g67f3ex5pmrtjlx83.jpg)
11.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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/09c7idw7zl7xwmb7fncg.png)
12.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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s1xv0gftpqksxegq7pmh.png)

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

![Terminal Emulator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ro2odqtstute0a1g4lxw.png)

14.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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qyd5c2v9t1u80uuvqjp0.png)

15.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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eizkp05tcico684kqnm8.png)

16.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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h4n2shbgpb7im0b13s9q.png)

17.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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e1e7ko1p3aj6cvg4k1n8.png)

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

![Finish Installation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v8u1m3o77ytmo9si3vu8.png)

19.Open Git Bash and yype `git --version` to confirm that Git is installed and working correctly.

![Git Bash](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bn3chrepbhuaignzgwfl.png)

## Installing Git on Linux
1.Open a terminal window and enter the following command to install Git:
```bash
sudo apt-get install git
```
2.After the installation is complete, enter the following command to verify that Git is installed:
```bash
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.
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
2.After Homebrew is installed, enter the following command to install Git:
```bash
brew install git
```
3.After the installation is complete, enter the following command to verify that Git is installed:
```bash
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 "youremail@example.com" with your own name and email address:
```bash
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
```
2.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:
```bash
ssh-keygen -t rsa -b 4096 -C "youremail@example.com"
```
3.Follow the prompts to generate your SSH key pair. Once it's done, enter the following command to display your public key:
```bash
cat ~/.ssh/id_rsa.pub
```
4.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 the official [GitHub docs](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) for more information.

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

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


Connect With Me :
{% embed https://dev.to/pratik_kale  %} 
[Website](https://pratikkale.in) | [Twitter](https://twitter.com/pratikkalein) | [Instagram](https://www.instagram.com/prato.grapher/) | [Mail](mailto:ppvkale@gmail.com)