DEV Community

Cover image for Setting up Git on Your Local Machine
Pratik Kale
Pratik Kale

Posted on • Updated on

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

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

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

Read and Accept
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

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

component selection

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

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

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
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
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
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
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

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

Terminal Emulator

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

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

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

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

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

Finish Installation

19.Open Git Bash and yype 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
Enter fullscreen mode Exit fullscreen mode

2.After the installation is complete, enter the following command to verify that Git is installed:

git --version
Enter fullscreen mode Exit fullscreen mode

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)"
Enter fullscreen mode Exit fullscreen mode

2.After Homebrew is installed, enter the following command to install Git:

brew install git
Enter fullscreen mode Exit fullscreen mode

3.After the installation is complete, enter the following command to verify that Git is installed:

git --version
Enter fullscreen mode Exit fullscreen mode

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:

git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
Enter fullscreen mode Exit fullscreen mode

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:

ssh-keygen -t rsa -b 4096 -C "youremail@example.com"
Enter fullscreen mode Exit fullscreen mode

3.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
Enter fullscreen mode Exit fullscreen mode

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 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 :



Website | Twitter | Instagram | Mail

Top comments (0)