How to Install Git on Windows

By

Learn how to install Git on Windows with the Git for Windows installer, choose the right setup options, verify the version, and configure your identity.

~~~

Installing Git on Windows is a straightforward process. First, you’ll need to download the Git for Windows installer. Head over to https://git-scm.com/install/windows in your web browser.

Git for Windows download page showing the automatic download link and manual download option

Click the download link at the top of the page to get the latest installer for your machine.

If you prefer the command line, you can install Git with winget instead, from the Command Prompt or PowerShell:

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

This runs the installer with the default options, so you can skip ahead to the part where we verify the installation.

Once you’ve downloaded the installer, run it. You’ll be presented with a series of options. For most users, the default settings work well, but let’s go through some key choices:

First it asks which editor Git should use. The default is Vim, which can be hard to use if you’ve never tried it, so pick an editor you already know, like Visual Studio Code. You can change it later too.

Next it asks for the name of the initial branch in new repositories. I pick “Override the default branch name for new repositories” and type main, which is the name GitHub uses too.

When asked about adjusting your PATH environment, select “Git from the command line and also from 3rd-party software”. This is usually the middle option and is what you’ll want in most cases.

For the SSH executable, stick with the default “Use bundled OpenSSH”.

For HTTPS transport backend, the default “Use the native Windows Secure Channel library” is fine.

When it comes to line ending conversions, choose “Checkout Windows-style, commit Unix-style line endings”. This option plays well with cross-platform projects.

For the terminal emulator, go with “Use MinTTY”, which is the default option.

For the default behavior of git pull, stick with “Default (fast-forward or merge)”.

For the credential helper, select “Git Credential Manager”.

In the extra options, enable “Enable file system caching” and “Enable symbolic links”.

After you’ve made these selections, proceed with the installation. Git will now install on your system.

To verify that Git has been installed correctly, open your Command Prompt (you can search for “cmd” in the Start menu) and type:

git --version

You should see a response with the Git version number, confirming that Git is now installed on your Windows machine.

Next, you’ll want to set up your identity. Git needs to know who you are when you’re making commits. Set this up by running these commands in the Command Prompt:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Replace “Your Name” and “[email protected]” with your actual name and email address.

If you’re using Visual Studio Code, you can set it as your default Git editor with this command:

git config --global core.editor "code --wait"

This will open VS Code whenever Git needs you to enter a commit message.

If you installed Git with winget, you never saw the installer screen where we set the initial branch name to main, so set it now:

git config --global init.defaultBranch main

Without it, git init names the first branch master and prints a hint about it, while GitHub names it main.

That’s it! You’ve now successfully installed Git on your Windows machine and set up the basic configuration. Keep my Git cheat sheet handy while you learn the commands.

Want to actually learn Git? Want to stop feeling frustrated with it? I created the Git Masterclass to solve this problem!

Tagged: Git · All topics

Want me to talk about your product? You can sponsor this site.

~~~

Related posts about git: