How to Install and Use Git on Windows

Try this guide with our instant dedicated server for as low as 40 Euros

How to Install and Use Git on Windows

Git is a popular open-source software tracking tool that lets users keep track of projects across several teams and revision levels. 

This open-source version control system (VCS) is used as a crucial development tool for source code management. Developers and managers use git to manage projects of all complexities and foster collaboration with multiple developers in real-time.

In a Windows environment, you can install git by following one of the two methods, GUI and Command Prompt. 

In this comprehensive guide, we will discuss both methods of installing git on Windows. Next, we will go into the details of configuring and launching git on your system. Finally, we will show you how to add a source to your git installation. 

Table Of Contents

  1. Install git on Windows
    1. The Prerequisites
    2. Method #1: Install Git Using GUI on Windows
    3. Method #2: Use CMD to Install git on Windows
  2. How to Launch Git in Windows
    1. Method #1: Launch Git Bash Shell
    2. Method #2: Start git GUI
  3. Configuration of git on Windows
    1. Factor #1: Identity Configure
    2. Factor #2: Modify the Default Text Editor
    3. Factor #3: Modify the Default Branch Name
  4. git on Windows: Set Up Your First Source
    1. Step #1: Check git Version
    2. Step #2: List All git Commands
    3. Step #3: Create and Initialize Test Directory
    4. Step #4: Clone GitHub Repository
    5. Step #5: Remote Repositories List
    6. Step #6: Push Local Files to Remote Repository
  5. Conclusion
  6. FAQs

Install git on Windows

You can install git on Windows in two different ways: 

  • GUI installer
  • Winget

The official git website offers a GUI installer wizard that walks you through configuring the git installation.

winget, a Windows CLI package manager modeled after Linux, simplifies software installation but offers fewer configuration options.

When deciding how to install git on Windows, consider your preference for control over the installation process and your comfort with the graphical user interface (GUI) versus the command-line interface (CLI).

The Prerequisites

Before moving in, ensure you have the following:

  • A stable Windows OS version
  • A user account with Administrator privileges

Method #1: Install Git Using GUI on Windows

This method is a good fit if you prefer having complete control over the installation process and avoid utilizing the CLI.

Follow these steps to install git using a GUI on Windows:

Step #1: Download the Installer File

Visit the official Git downloads page.

Select the most recent git version for Windows and download the installer.

git download for windows

The latest available git version is 64-bit Windows. Therefore, ensure you have a 64-bit OS on your system. Otherwise, download the 32-bit git installation file.

Next, double-click the file downloaded to extract and launch the installer. You will then be prompted to go to the GNU General Public License page.

Once you finish reading, click Next to start the installation.

gnu general public license

Step #2: Select Destination Location

Click Browse to choose an installation location or Next to leave the default value.

select destination location

Step #3: Select Components

In the Component Selection screen, select the components you want to install or leave the default to be installed.

Click Next to continue.

select components

Step #4: Select Start Menu Folder

The installer suggests creating a git folder in the Start menu. 

Click Browse if you prefer to select a different folder. If not, click Next to continue.

select start menu folder

Step #5: Select Text Editor

Next, choose your preferred text editor from the drop-down menu. The default editor is Notepad++.

Once you have selected the text editor, click Next to continue.

choosing the default editor used by git

Step #6: Name the Initial Branch in the New Repository

Next, you will be prompted to choose a name for your main branch in new repositories. Unless you are working in a team that requires a different name, choose the default option.

Click Next to continue.

Name the Initial Branch in the New Repository

Step #7: Adjust the PATH Environment

Following this, you will be now prompted to choose the PATH environment variable. 

The PATH is the default list of folders that the system searches for when running commands or launching applications. 

We recommend choosing the Use recommended settings option. Click Next to continue.

Adjust the PATH Environment

Step #8: Select the SSH Client

Next, the installation prompts you to choose an SSH client. 

SSH is used for secure communication with remote servers. By default, git uses its built-in SSH client. You can choose to go with this or use a different one if needed.

Click Next to continue.

Select the SSH Client

Step #9: Select the HTTPS Option

Next, choose the server certificates. We recommend choosing the default option. If you work in an Active Directory environment, you may need to convert to Windows Store certificates. 

Once you have selected your certificate option, click Next to continue.

Select the HTTPS Option

Step #10: Configure Line-Ending Conversion

Select the preferred option for configuring line-ending conversion. We recommend choosing the default selection for Windows. 

Click Next to continue.

Configure Line-Ending Conversion

Step #11: Configure the Terminal Emulator

Next, select the preferred terminal emulator. We suggest going with the default option, MinTTY due to its many features.

Click Next to continue.

Configure the Terminal Emulator

Step #12: Choose Default Behavior

Next, choose the default behavior of the git pull command. 

We advise you to leave the default setting, except in rare cases where changing its functionality is an operational requirement. 

Click Next to start the installation process.

Choose Default Behavior

Step #13: Choose a Credential Helper

git uses credential helpers to store and retrieve credentials. You can go with the default option as it is the most reliable option. 

Once you have chosen your preferred credential manager, click Next.

Choose a Credential Helper

Step #14: Configure Extra Options

The next step lets you decide which extra options to enable. If you use symbolic links, which represent shortcuts for the command line, tick the box. 

Ensure you keep the file system caching checked.

Click Next to continue.

Configure Extra Options

Step #15: Configure the Experimental Options

The next stage allows you to select additional options to activate. Check the option to use symbolic links, which are command-line shortcuts. 

Once file system caching is enabled, click Install to continue.

Configure the Experimental Options

Step #15: Complete the Setup

Once the installation is complete, check the boxes to view Release Notes and open git Bash immediately.

Click Finish to complete the setup.

Complete the Setup

Method #2: Use CMD to Install git on Windows.

By now you have understood how to install git on Windows using GUI. 

Now let us consider the second way of installing git on Windows through the command prompt.

Installing git on Windows using the command line requires a working winget installation, an Internet connection for the program to download the necessary files, and access to the Command Prompt or PowerShell.

If you prefer using a package manager, follow these steps to install and manage programs:

Start by running the Windows PowerShell. Remember to select the Run as administrator option.

run the windows powershell

Install the most recent git version with the following command in PowerShell:

> winget install --id Git.Git -e --source winget

winget install

The command downloads and installs Git for Windows. It assumes all the default settings and completes the installation automatically.

How to Launch Git in Windows

Like the installation, you can launch git on Windows in two easy methods: 

  • Via the command line using a Bash script.
  • Through the Graphical User Interface (GUI). 

Let us run through these methods to see the steps involved. 

Method #1: Launch Git Bash Shell

Open the Windows Start menu and search for git bash. The git will be launched using the Bash Shell. 

Launch Git Bash Shell

Method #2: Start git GUI

Open the Windows Start menu and type git gui.

Press Enter or click the application icon to start git GUI.

Start git GUI

Configuration of git on Windows

Before you can start using git, you need to configure it for improved usability and enhanced efficiency.

Therefore, once the git is installed on Windows, start by configuring certain options to customize the git environment. Most of these configurations persist (stick) between version upgrades, so you need to configure them only once after a fresh install.

Factor #1: Identity Configure

git uses your email address and username to identify you each time you initiate a commit. We recommend the following command syntax in git Bash to verify your identity:

> git config --global user.name "[username]"

Replace [username] with the desired username. If you have a GitHub account, you can use its username and email address.

> git config --global user.email [email]

Now, replace [email] with the desired email.

Factor #2: Modify the Default Text Editor

The default text editor for git is usually the same as your system’s default editor unless you specify something different during the installation. You can change this selection to use a different editor as default. 

Open the Command Prompt or git Bash.

Run the following command, replacing [path_to_editor_exe_file] with the actual path to your editor’s executable file.

> git config --global core.editor [path_to_editor_exe_file]

The path to the executable file may vary depending on how your editor is packaged and whether you use a 32-bit or 64-bit system.

For instance, run the following command to enable Notepad++ as the git default editor:

> git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

Here,

-multiInst: Opens a new instance of Notepad++ for each git edit session.

-notabbar: Hides the tab bar in Notepad++.

-nosession: Prevents loading previous sessions when opening Notepad++.

-noPlugin: Disables plugin loading in Notepad++ for faster startup.

Factor #3: Modify the Default Branch Name

By default, git uses Master as the branch name for newly created repositories. However, some developers prefer Main as the standard branch name. 

Open your Command Prompt or git bash.

Run the following command, replacing [branch_name] with your desired default branch name:

> git config --global init.defaultBranch [branch_name]

For instance, use this command to set the default branch name to main:

> git config --global init.defaultBranch main

git on Windows: Set Up Your First Source

Now that you have git installed and configured, let’s dive into using it to manage your first source code project. You will learn how to set up a test directory, submit work, and verify git version.

Before moving in, ensure you have a GitHub username and password as we will access a remote repository.

Step #1: Check git Version

Start by checking the git version installed on your system. 

Launch PowerShell and run the following command to check the git version: 

> git --version

git --version

The output displays the git version installed.

Step #2: List All git Commands

The git installation comes with a help file that contains a collection of the most frequently used commands. 

To view the help file, run the following command in Windows PowerShell or git bash:

> git help -a

git help -a

The output displays the most frequently used git commands.

Step #3: Create and Initialize Test Directory

Next, create a new directory and set it up as a git repository.

For this, open git bash or a Windows PowerShell interface. Create a new test directory with the following syntax:

> mkdir [directory_name]

Navigate to the newly created directory using the cd command:

> cd [directory_name]

Next, set up the directory as a git repository:

> git init

git init

Step #4: Clone GitHub Repository

You can clone a repository from GitHub to your Windows platform to start synching the local and GitHub repository versions:

Start by navigating to your repository on GitHub in a browser tab. Click the Code button and select the HTTPS or SSH option, depending on how you want to secure your connection.

Copy the URL for cloning the repository.

Note: To clone a repository using SSH, you must generate an SSH key pair on your Windows workstation and assign the Public key to your GitHub account.

Open git bash or Windows PowerShell and clone the repository with this command:

> git clone [repository_url]

Replace [repository_url] with the URL you copied on GitHub. 

Step #5: Remote Repositories List 

Once you’ve successfully cloned a remote repository from GitHub, you’ll have a local copy of the project on your machine. This local repository will be typically located in a new directory named after the original repository on GitHub.

Next, use cd command to navigate to the directory:

> cd [repository_name]

Here, replace [repository_name] with the actual name of the repository you downloaded.

If this isn’t working, use the dir command to list the contents of the current directory.

This is helpful if you need to double-check your spelling or don’t know the exact name.

Once you are in the subdirectory, list the remote repositories using this command:

> git remote -v

Step #6: Push Local Files to Remote Repository

Now, you can carry out essential git-related tasks, such as making a new file, adding it to the tracking index, and pushing the updated version to the remote repository. 

Launch git bash and use the touch command to create a new file:

> touch rstext.txt

Next, include the newly added file to the tracking index.

> git add rstext.txt

If you’ve created more than one file, you can track them all by executing:

> git add 

Next, confirm that the rstext.txt file has been inserted in the tracking index with this command.

> git status

Next, commit the changes using the following command:

> git commit -m "[commit_message]"

You can add a commit message to the commit command using the -m option. git opens the integrated text editor where you can write the commit message if you omit the -m option.

Finally, you can sync the changes to the GitHub repository:

> git push [remote_repository]

Replace [remote_repository] with the name of your remote repository.

If you have a Linux system, you can install git by following our comprehensive tutorial on installing git on Ubuntu

Conclusion

git is easy to install and use on Windows, enabling users to manage their version-controlled projects efficiently. Users may effortlessly install git on their Windows computers and take advantage of its robust features for collaborative software development by following the instructions in this article. git offers an extensive version control platform that can be used for anything from starting up a repository to committing changes and working with other team members. It helps developers track project progress, maintain code integrity, and optimize workflow. These features boost productivity and make it easier for developers to collaborate on Windows systems.

FAQs

Q. What is git, and why is it used?

During software development, source code changes are tracked using the git version control system. It guarantees effective project revision management and facilitates cooperation amongst several developers.

Q. How do I install git on Windows?

To install git on Windows, use package managers like Chocolatey or download the git for Windows installer from the official website. To finish the setup, adhere to the installation guidelines supplied.

Q. What is the git bash terminal, and why should I use it?

git bash is a command-line interface (CLI) that offers a Unix-like environment on Windows. It allows users to interact with git using familiar Unix commands, making it preferable for those comfortable with CLI operations.

Q. How do I configure git after installation?

Use the git config command to set up your email address and log in after installing git. This data makes it easier to find your commits. You can also customize other settings like default text editors and merge tools.

Q. How do I create a new git repository on Windows?

To initiate a new git repository, navigate to the desired directory in git Bash or the command prompt and execute the git init command. In the provided directory, this command creates a new git repository from scratch.

Q. How do I clone an existing git repository on Windows?

Use the git clone command and the repository’s URL to clone an existing git repository. This command makes a local copy of the repository on your Windows computer.

Q. What are some basic git commands I need to know?

Essential Git commands include git add (to stage changes), git commit (to commit changes), git push (to push changes to a remote repository), git pull (to fetch and merge changes), and git status (to view the repository status).

Q. How can I use git on Windows to collaborate with others?

Collaborating with others involves pushing your changes to a remote repository and inviting collaborators to contribute. Additionally, you can pull updates from your local repository to your remote repository. 

Q. Where can I locate more guides and tutorials for Windows git learning?

Explore online documentation, tutorials on platforms like GitHub and Atlassian, and courses on educational websites like Coursera and Udemy for comprehensive git learning resources.

Q. Can I use graphical user interfaces (GUIs) with git on Windows?

For Windows, there are a number of GUI-based git clients that provide aesthetically pleasing interfaces for managing git repositories, including GitKraken, Sourcetree, and GitHub Desktop.

Try this guide with our instant dedicated server for as low as 40 Euros