How to Set Up Git on Windows – A Beginner's Guide

Renu SaharanRenu Saharan
3 min read

Introduction: Git is a powerful version control system that helps developers track changes, collaborate on projects, and manage code efficiently. Whether you're a beginner or an experienced developer, setting up Git on Windows is a fundamental step to streamline your development workflow. This guide will walk you through the entire process of installing and configuring Git on your Windows machine.


Step 1: Download Git for Windows

  1. Open your web browser and navigate to the official Git website.

  2. Click on the "Download" button. Git will automatically detect your operating system and provide the correct version for Windows.

  3. Once the download is complete, open the installer by double-clicking on the .exe file.

Step 2: Install Git on Windows

  1. When the Git Setup wizard opens, click "Next" to begin the installation.

  2. Select Destination Location: Choose the folder where you want Git to be installed (default is recommended).

  3. Select Components: Leave the default options selected unless you have specific requirements.

  4. Adjusting Your PATH Environment: Choose "Git from the command line and also from 3rd-party software" to access Git from both Command Prompt and PowerShell.

  5. Choosing HTTPS Transport Backend: Select "Use the OpenSSL library" for secure HTTPS connections.

  6. Configuring Line Ending Conversions: Choose "Checkout Windows-style, commit Unix-style line endings" (recommended for cross-platform work).

  7. Terminal Emulator: Choose "Use MinTTY" for a better terminal experience.

  8. Click "Next" until you reach the "Install" button, then click "Install" to start the installation process.

  9. Once the installation is complete, click "Finish".

Step 3: Verify Git Installation

  1. Open the Command Prompt (Press Win + R, type cmd, and hit Enter).

  2. Type the following command to check if Git is installed correctly:

     git --version
    

    If Git is installed properly, you will see the installed version number (e.g., git version 2.x.x).

Step 4: Configure Git

To use Git effectively, you must configure your user information.

  1. Set your username:

     git config --global user.name "Your Name"
    
  2. Set your email address:

     git config --global user.email "your.email@example.com"
    
  3. Verify your configuration:

     git config --list
    

    This will display all the Git configurations you've set.

Step 5: Set Up SSH Authentication (Optional)

If you plan to interact with remote repositories over SSH, follow these steps:

  1. Generate an SSH key:

     ssh-keygen -t rsa -b 4096 -C "your.email@example.com"
    

    Press Enter to accept the default file location and optional passphrase.

  2. Add the SSH key to the SSH agent:

     eval $(ssh-agent -s)
     ssh-add ~/.ssh/id_rsa
    
  3. Copy the SSH key to your clipboard:

     clip < ~/.ssh/id_rsa.pub
    
  4. Add the SSH key to your Git provider (e.g., GitHub, GitLab) by pasting it into the appropriate SSH key section.

Step 6: Clone a Repository (Optional Test)

You can test your Git setup by cloning a sample repository:

git clone https://github.com/example/repo.git

If the repository is cloned successfully, your Git installation is working correctly.


Conclusion: You've successfully set up Git on your Windows machine! You're now ready to track your code, collaborate with others, and contribute to projects. Keep exploring Git commands and workflows to master version control.

1
Subscribe to my newsletter

Read articles from Renu Saharan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Renu Saharan
Renu Saharan