Skip to content

Installing and Configuring Git

This guide provides instructions on how to install and configure Git on your system. Git is a distributed version control system that is essential for collaborating on software projects.

Prerequisites

Before proceeding, ensure you have a terminal or command prompt open.

Installation

1. Verify Installation

Before installing, check if Git is already installed on your system. Open your terminal (PowerShell on Windows, Terminal on macOS/Linux) and run:

git --version

If a version number is displayed (e.g., git version 2.x.x), Git is already installed. If you receive an error or want to update to the latest version, proceed to the installation steps below.

2. Install Git

Windows & Linux

Visit the official Git website to download and install the latest version for your operating system:

macOS

You can install Git using the Xcode Command Line Tools, which is often the easiest method. Run the following command in your terminal:

xcode-select --install

Alternatively, you can download the installer from the official Git website.

Initial Configuration

After installing Git, you must configure your username and email address. This information is embedded in every commit you create.

1. Set User Name

Replace "Your Name" with your actual name. This information is available publicly on commits.

git config --global user.name "Your Name"

2. Set User Email

Replace "your.email@example.com" with the email address you use for your Git provider (GitHub, GitLab, etc.). This information is available publicly on commits.

git config --global user.email "your.email@example.com"

3. Set Default Branch Name (Optional)

It is common practice to use main as the default branch name.

git config --global init.defaultBranch main

4. Windows Specific: Configure OpenSSH

If you are using Windows, it is recommended to configure Git to use the built-in Windows OpenSSH client for better compatibility with SSH keys. Run this in PowerShell:

git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe

5. Verify Configuration

You can check your configuration settings by running:

git config --list

Next Steps

Now that Git is installed and configured, you are ready to set up secure authentication. * Using SSH Keys with Git