Git is the most popular version control system (VCS) among programmers and developers for software development. It’s free and open-source and available for all major operating systems: Linux, macOS, and Windows.

installing and configuring git on windows

If you’re new to software development, learning Git is considered an essential skill. But in order to get started, the first step is to install and configure it on your computer.

However, since this can be confusing for some, here’s a guide discussing Git and demonstrating the steps to install and configure Git on Windows.

What Is Git and Why Do You Need It?

Git is a distributed version control system used to collaborate and maintain projects. It was created by Linus Torvalds for the development of the Linux kernel and later ported to macOS and Windows operating systems.

Being a DVCS, Git doesn’t have a centralized repository. Instead, when someone clones a Git repository, it’s mirrored entirely on that person’s computer along with the complete history of changes ever made to it.

Using Git, you can manage all your projects and collaborate with other developers in real-time quickly and efficiently without risking the chances of accidentally modifying the original source code (or project files).

Following are some of the reasons why you need to use Git:

  • It simplifies and speeds up the process of managing project files.
  • It allows multiple developers to work on a project simultaneously.
  • It helps avoid code conflicts in a project with multiple developers.
  • It mirrors a repository as is on a system to allow you to work independently—even offline.
  • It allows you to track changes made to a file.
  • It lets you restore previous versions of files in case of mistaken changes.

How to Install Git on Windows

Git can be installed on Windows in a few different ways. You can either use an automated installation setup or take advantage of the Chocolatey package manager to install Git via the command line or install it directory from the source for the latest version.

1. Installing Git Using Chocolatey

Chocolatey is a Windows package manager that helps you install and update software packages on your Windows PC. It works with all versions of Windows, starting with Windows 7.

To use Chocolatey, you first need to install it on your PC. For this, open the Windows Command Prompt with administrative privileges and run the following command:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Alternatively, you can run PowerShell with administrative privileges and run:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Once Chocolatey is installed, restart the CMD or PowerShell. Now, enter the command below and hit Enter to install Git on your computer:
choco install git.install

Follow the prompts to finish the installation. When it’s finished, use the following command to verify the installation:
git --version

To upgrade Git, run:
choco upgrade git.install

2. Installing Git Using Installer

If you’re not comfortable working with a CLI, you can use the Git installer to install Git on your Windows PC. To do this, first, download the Git installer from the link below.

Download: Git Installer

Once downloaded, run the file. On the User Account Control prompt, tap Yes to bring up the installation window.

Hit Next to continue with the setup.

installing git on windows

On the Select Components window, tick the checkboxes for Additional icons, Windows Explorer integration (Git Bash Here and Git GUI Here), and Add a Git Bash Profile to Windows Terminal. Click Next.

installing git on windows

When asked to choose the default editor for Git, hit the dropdown button and select your editor of choice. By default, Git is set to use the Vim text editor, but since it can be intimidating for some, there are other text editors to choose from, such as Atom, Notepad++, Visual Studio Code, and Sublime Text. Select one and hit Next.

installing git on windows

Next, you need to set the default name for the initial branch you create in your repositories. Selecting Let Git decide uses master, which is what most people use. However, you can set a custom name by choosing Overrise the default branch name for new repositories and entering the name in the text field below. Once selected, tap Next.

installing git on windows

On the Adjusting your PATH environment screen, select Git from the command line and also from 3rd-party software. Doing so will allow you to use Git from Git Bash, Command Prompt, PowerShell, or any other software. Click Next to proceed.

installing git on windows

Choose Use the OpenSSL library as the transport backend to validate server certificates and click Next.

In the line ending conversions options, choose Checkout Windows-style, commit Unix-style endings to avoid cross-platform compatibility issues. Hit Next.

Now, select MinTTY (the default terminal of MSYS2) for better compatibility and hit Next.

installing git on windowsFor the default git pull behavior, choose Default (fast-forward or merge). With this setting, when you use git pull, it’ll fast-forward the current branch to the fetches brand when possible. If not, it’ll create a merge commit. Click on Next to proceed.

When asked to choose a credential helper, select Git Credential Manager Core and hit Next.

installing git on windows

On the extra options screen, check off Enable file system caching to speed up your Git operations and click Next. If you want, you can also select Enable symbolic links to improve pathname resolution.

Leave the experimental features unselected and tap Install to begin Git installation on your PC. Once it’s complete, hit Finish.

Now, to confirm if Git has been installed, Run Git Bash. Alternatively, open CMD with administrative privileges and run:
git --version

If it returns a version number, this means Git is installed and ready to use.

How to Configure Git on Windows

Once you’ve installed Git on your PC, it’s time to configure some of its settings to adjust its look and behavior. You only need to do this once, and the configurations will stick around forever—even after you update Git.

Setting Up User Identity

First things first, every commit you make to Git repositories requires a username and email address attached to it. To avoid having to feed it for your every commit, Git lets you set up your default user identity. That way, all your commits use the same identity (username and email address).

To set up your identity, in an elevated Command Prompt, run:
git config --global user.name "Your Name"
git config --global user.email youremail@example.com

Here, –global option will set your default identity for all repositories. However, if you’d like to set it for a particular repository, you can do so by going into that repository folder and running the command without the –global option.

Once done, verify the changes by running:
git config --list

gitconfig file output

Alternatively, you can also access the Git config file by navigating to C:\Users\user_name\ and finding the .gitconfig file.

Configuring SSH for Git on Windows

SSH (Secure SHell) is a protocol for secure network communication between two systems. Using SSH with Git allows you to securely move files between your PC and Git repositories and issue various Git commands remotely over a secure channel.

Not just that, but it also allows takes away the need to feed in your username and password every time you want to commit changes to a repository.

To generate an SSH key, open Git Bash and run the following command:
ssh-keygen -t rsa -b 4096 -C "your_email_address"

Next, it’ll prompt you to confirm the location to store the SSH key. Hit Enter to continue with the default location. You now need to set a passphrase to add an extra layer of security to SSH. Enter a strong password and press Enter.

Lastly, you now need to add the SSH key to the SSH agent. To do this, you first need to enable OpenSSH. For this, open Task Manager (Ctrl + Shift + Esc), click on the Services tab, and tap on Open Services at the bottom.

configuring ssh on windows

Here, find OpenSSH Authentication Agent and double-click on it. Tap the Start button below Service status to start it and click OK.

configuring ssh on windows

Now, open CMD in elevated mode and run:
start-ssh-agent

Once the SSH agent is up and running, go to Git Bash and run the command below to add the SSH key you generated a few steps earlier:
ssh-add ~/.ssh/id_rsa

When prompted for a passphrase, enter one you set earlier and hit Enter to set the identity.

Successfully Managing Your Projects With Git

If you followed this guide closely, you should have Git up and running on your Windows computer. And subsequently, you should be able to use it to manage all your project files and collaborate with other developers (if you’re working with a team).

Furthermore, to take your experience up a notch and manage your Git repositories more efficiently, you can also use GitHub: a cloud-based hosting service for managing Git repositories.

Was this article helpful?
YesNo