How to Install Git on Windows 10

This article details the steps of installing and configuring Git on Microsoft Windows 10. Git is a version control system, a system that keeps track of any modifications in the source code. It keeps different versions of your source code so we can easily retrieve a previous version of your code when you make a mistake.

We can install Git Bash on Windows 10 using the Chocolatey software package manager.

Our first step is to install Chocolatey, if not installed already on your Windows 10 PC. We can do this by opening a PowerShell Window (as Administrator) and running the following command:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

After that, we need to close and reopen the PowerShell.

To install Git for Windows with Chocolatey, execute the following command:

choco install -y git

Close and Reopen the PowerShell again. Then, check whether Git has installed successfully with the following command:

git --version
Check Git Version
Check Git Version

Configuring and Initializing a Repository

Before using Git in a project, we need to configure git with our username and e-mail address.

git config --global user.name your_username
git config --global user.email your_email@example.com

To check the configuration settings for your repository, you can run the following command:

git config --global --list

If you have a project folder that is not currently using Git version control, open the folder, right-click on an empty place on the folder and choose the menu item "Git Bash Here". It will open the Windows Git Bash terminal in your current working directory.

Git Bash Here

To initialize the new project, run the following command in the terminal:

git init

The git init command is the command that allows us to create a local repository in Windows 10. The init command creates the .git subfolder (inside your current working directory) that contains all of the folders and configuration files of the local repository.

Install Git on Windows 10