Skip
Arish's avatar

7. Installing Git on Windows


Installing Git on Windows

Let's install Git on Windows step by step.

Download Git for Windows

  1. Go to git-scm.com/download/win
  2. The download should start automatically
  3. If not, click the download link

Run the Installer

  1. Run the downloaded .exe file
  2. Accept the license agreement
  3. Choose installation options (defaults are fine for most users)

Key Installation Options

Select Components

  • ✅ Git Bash Here
  • ✅ Git GUI Here
  • ✅ Associate .git* configuration files with the default text editor

Default Editor

Choose your preferred editor:

  • VS Code (recommended)
  • Notepad++
  • Vim

PATH Environment

Select: Git from the command line and also from 3rd-party software

This allows you to use Git in Command Prompt, PowerShell, and Git Bash.

Line Ending Conversions

Select: Checkout Windows-style, commit Unix-style line endings

This is the recommended option for Windows users.

Verify Installation

Open a new terminal (Command Prompt, PowerShell, or Git Bash):

bash
1git --version
2# Output: git version 2.43.0.windows.1

Configure Git

Set your identity:

bash
1# Set your name
2git config --global user.name "Your Name"
3
4# Set your email
5git config --global user.email "your.email@example.com"

Verify Configuration

bash
1git config --list

Git Bash vs Command Prompt

Git Bash

Git Bash provides a Unix-like terminal experience on Windows:

bash
1# Unix commands work in Git Bash
2ls -la
3pwd
4mkdir new-folder

Command Prompt / PowerShell

Standard Windows terminals also work with Git:

cmd
1# Windows commands
2dir
3cd
4mkdir new-folder

Recommendation: Use Git Bash for a consistent experience with tutorials and documentation.

Set Default Editor

bash
1# For VS Code
2git config --global core.editor "code --wait"
3
4# For Notepad++
5git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

Set Default Branch Name

bash
1git config --global init.defaultBranch main

Test Your Installation

bash
1# Create a test folder
2mkdir git-test
3cd git-test
4
5# Initialize a repository
6git init
7
8# Create a test file
9echo "Hello Git" > test.txt
10
11# Stage and commit
12git add test.txt
13git commit -m "Initial commit"
14
15# Success!

Windows Credential Manager

Git for Windows includes a credential manager that securely stores your GitHub credentials:

bash
1# Check credential helper
2git config --global credential.helper
3
4# Should output: manager-core (or manager)

Troubleshooting

'git' is not recognized

If Command Prompt doesn't recognize git:

  1. Close and reopen Command Prompt
  2. Verify PATH includes Git: echo %PATH%
  3. Reinstall Git and ensure "Add to PATH" is selected

Line Ending Issues

If you see warnings about line endings:

bash
1git config --global core.autocrlf true

SSL Certificate Issues

If you encounter SSL errors:

bash
1git config --global http.sslVerify true

Summary

You've installed Git on Windows! Remember:

  1. Git Bash provides a Unix-like experience
  2. Command Prompt works too
  3. Configure your name and email
  4. Test with a sample repository

Next, let's install Git on Linux!