5 Ways to install Git on Windows 11 PC

5 Ways to install Git on Windows 11 PC

5/5 - (43 votes)

In this guide we will learn 5 Ways to install Git on Windows 11 PC .

How to install Git on Windows 11

Since there are a few ways to install Git, we will look at the methods one by one so you can see the steps to install Git for all the different methods.

Method 1: Install Git from the Git official page

Now, let’s take a look at how to install Git the traditional way. Here’s how to go about it:

Step 1: Download Git

The first step is to get the Git setup file. To do so, click on the following link:

Download: Git Official page

On the downloads page, click on Windows to get the latest setup file.

Step 2: Run Git setup

Now, navigate to the downloaded setup file and double-click to run the installer. Click Next.

Keep the default installation location, and click Next.

On the next screen, you’ll be able to select which components you want to install. Unless you need to change something specifically, we recommend keeping the options set to default. Then click Next.

Click Next again.

On the next screen, you’ll have to choose the default editor for Git. Click on the drop-down menu to do so.

Then select your text editor. We are going with Notepad++.

Click Next.

On the next screen, you’ll have the option to choose a different name for the initial branch in new repositories. The default name is ‘master’. Keep it that way unless you want a different one, and click Next.

The next step adds the PATH environment for Git when running commands from command-line applications (such as CMD and PowerShell). Keep it set to default, and click Next.

Now, choose the Secure Shell client program for Git to use. As the installer comes bundled with the OpenSSH, there are no changes required here (unless you want to use an external OpenSSH). Click Next.

When choosing server certificates, we recommend using the default OpenSSL library. Click Next.

This section lets you configure line-ending conversations. Leave it as set to default, then click Next.

Now choose your terminal emulator. Again, we’d recommend sticking with the default MinTTY. Click Next.

Keep the default behavior of the command git pull. As before, if you don’t want to change its behavior, the default option is recommended. Click Next.

Now, you have to choose a credential helper that will help get and save credentials. The Git Credential Manager core (default selection) is the most stable one of the lot, so just click Next.

There are a few extras to configure as well. The first option (selected by default) is to “Enable file system caching”. This is important for certain functions and also gives a significant performance boost. The other option is to “Enable symbolic links” which are similar to command-line shortcuts. Select it if you use them, or leave it be if you don’t. Then click Next.

The last few options you get are “support for pseudo consoles” and a “built-in file system monitor”. These are experimental features that are being actively developed. So, unless you want to try them out, we recommend leaving them unchecked. Then, finally, click on Install.

Once the installation is complete, click Finish.

Related: All the Windows 11 Shortcuts

Step 3: Check Git version

Once you’ve installed Git, it’s time to check if Git is installed properly and its version. To do this, launch the Git Bash from the Start menu.

Then type the following command and hit enter:

git --version

You should see the git version installed on your PC.

Step 4: Configure Git with username and email

To start using Git on Windows 11, you need to configure it by entering your credentials. Here is how you can do so:

Open Git Bash, then type the following to add your user name:

git config --global user.name "your user name"

Make sure to replace “your user name” with your actual username. Then press Enter.

Now type the following command:

git config --global user.email "your email address"

Again, make sure to replace “your email address” with your actual email address associated with your Git account. Then press Enter.

Now, if you want to check the configuration, type the following:

git config --global --list

Then press Enter.

You will see your configuration details.

Note: The --global command tells Git to use the information you provided for all that you do on your system. If you use --local instead, the configuration will only apply to your current repository.  

Related: How to Change a Wallpaper on Windows 11

Method 2: Install GitHub Desktop for Windows 11

If you’re looking to get a GUI-aided application to manage your Git repositories and have others collaborate on it, GitHub Desktop is your friend. Its installation is also a very simple process. 

Download: GitHub Desktop

Go to the above link and click on Download for Windows (64-bit)

Then run the downloaded setup. The setup won’t require any changes and install GitHub automatically. Upon launch, you have the option to sign in to GitHub.com. Or you can go ahead and Skip this step.

Type in your username and email. Then click Finish.

And that’s it! GitHub Desktop is now ready to use.

Related: How to Install PIP on Windows 11

Method 3: Use Git with PowerShell

There’s a common misconception that Git only works well with Git Bash when in fact it works just as nicely on PowerShell too. But there’s a little addition that you have to make to PowerShell before that can be done.

Step 1: Check for Execution Policy

First up, you need to have the PowerShell ExecutionPolicy set to “RemoteSigned”. So press Start, type powershell, and click on Run as administrator.

Now type the following command in PowerShell:

Get-ExecutionPolicy

Press Enter.

If you receive the “RemoteSigned” message, then it is already set.

If not, then type the following command:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force

Then press Enter.

Now you’re ready to install the git module in PowerShell. 

Step 2: Add the Posh-git module

To add the Posh-git module, type the following command:

Install-Module posh-git -Scope CurrentUser -Force

Then press Enter.

Next, we’re going to import the module into PowerShell. To do this, type the following command:

Import-Module posh-git

Press Enter.

You may want to make sure that the module loads as default. For this, type the following command:

Add-PoshGitToProfile -AllHosts

Press Enter.

You are now ready to use PowerShell for your git experience whenever you’re in a directory with a git repository.  

Method 4: Install Git on Ubuntu WSL

If you’ve installed Ubuntu on Windows Subsystem for Linux (WSL), you can also install Git on it. Here’s how to go about it.

Open the Ubuntu App.

Then type the following command:

sudo add-apt-repository ppa:git-core/ppa

Press Enter. 

Then enter your password and press Enter.

Press Enter to continue adding the git repository.

Now type the following command to update it.

sudo apt-get update

Press Enter.

Now type the following to install git:

sudo apt-get install git

Press Enter.

When asked to confirm, type Y and press Enter.

You have now installed Git on Ubuntu WSL.

Method 5: Install Git using the Winget tool

There is a little-known tool on Windows 11 called the winget command line tool that lets you find, install, configure, and remove apps on your system. It can be used to install Git on Windows as well.

On Windows 11, the winget tool would already be installed so there’s no need to install it separately. Here’s how to use it to install Git on Windows:

Press Start, type powershell, then right-click the best-matched result and select Run as administrator.

Then type the following command:

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

Press Enter.

Wait for git to be downloaded and installed.

Once finished, you will see the message “Successfully installed”.

How to use Git on Windows 11

Now that we have looked at the various means of installing Git on Windows 11, let’s now see how to go about using Git. Here are a few things that you might want to learn how to do with Git:

1. Create and initialize a local test directory

To create a new local test directory, enter the following in Git Bash or PowerShell:

mkdir test

Hit Enter. If you already have a GitHub repository, type the name of the project instead of test.

Then, to change directory, type the following:

cd test

Hit Enter. Now, to initialize the git in the new directory, type the following:

git init

Hit Enter.

If you want to add a few project files, you can simply enter the full name of the project file. For instance, if you want to create a text document, you will type the following:

notepad test.txt

Hit Enter. This will open the said app. 

Add the relevant content. Then save the file.

You can track your file by the following command and hitting Enter:

git status

Here, you’ll see that Git recognizes our files but hasn’t found any commits (or saves) to the file as mentioned in the message – “No commits yet” and “Untracked files”.

2. Create a new remote repository

Firstly, go to github.com and sign in. Then click on the ‘+’ icon towards the top right corner. 

Select New repository.

Here, enter a name for your repository under “Repository name”. If it’s available, you’ll get a green tick.

Give your repository a description (optional) and select from Public or Private.

Then click on Create repository at the bottom.

Your repository is now created. Here, copy the HTTPS URL of your repository. 

3. Use Git commit command to save changes

As you’re working with Git, you can commit your changes to provide a checkpoint for your work at any point. Think of it as saving your work along the way so that you can look back on these commit checkpoints and see where the changes to a code first appeared.

But before committing a change, it first has to be staged. Staging simply means you’re preparing to commit the file(s). For our example, we’re staging to commit the test.txt file. Here’s the command for it:

git add test.txt

Hit Enter. For multiple files, type the following:

git add --all

Now, to commit the changes, type the following command:

git commit -m "commit message"

Replace the words within the quotation marks with a short commit message of your own. Then hit Enter.

4. Push local files to a remote repository

Now, let’s consider pushing these local files to a remote repository, like the one created earlier.

The local files on your system in themselves work as a ‘clone’ for the ones that sit in your remote repository. All we have to do is switch the origin of these files to your remote repository. For this, follow the steps below:

Login to your GitHub account and go to your repository and copy the repository URL.

Then switch to Git Bash. Then type the following:

git branch -M main

Hit Enter.

Then type this:

git remote add origin repository_url

Replace repository_url by the one copied earlier.

Then hit Enter

Not type this:

git push -u origin main

Hit Enter. And just like that, your local files are now on your repository online which will now become its main source.

5. How to clone a GitHub repository

Cloning a GitHub repository is quite simple. Go to your remote repository and copy its URL.

Once you’ve copied the URL of your repository, return to your Git Bash or PowerShell window. Then type the following command:

git clone "repository-url"

Replace repository-url with the copied URL of the repository. Then hit Enter.

And that’s about it!

Frequently Asked Questions (FAQs)

Installing git to manage application versions and collaborating with others can be a little tricky for beginners and it’s natural to have questions about it. Here we address a few commonly asked queries that users generally have when installing git on Windows 11.

Can I use git in cmd?

When you install the Git GUI, you also install Git Bash and Git CMD. The latter is a command-line tool that is exactly like the Windows console but better at all things related to Git.    

What is the difference between local and remote git repositories?

Git repos (short for repositories) come in two kinds – local and remote. In simplest terms, the local git repository is the one that you create and manage locally, that is, on your computer alone. Its features and functions are exactly like any other git repository. 

On the other hand, the purpose of a remote repository (such as GitHub) is to share your own codes and files with the world, allowing others to branch, merge, rebase, etc.  

Does installing GitHub install Git?

Yes, if you don’t already have git, GitHub will install git’s latest version as well. 

We hope you were able to easily install git on your Windows 11 PC.