How to Install Git on Windows and Linux (Step by Step)

Before you can use Git, it has to be installed on your computer. This lesson walks you through installing Git on Windows (with the installer or winget) and on the most popular Linux distributions, with the installer options that matter and fixes for common problems.

Advertisement

📖 What You’ll Learn: checking for an existing Git, the Git for Windows installer and its key options, installing with winget, installing on Ubuntu, Fedora, Arch and others, updating Git, and troubleshooting.


✅ Before You Start

Check whether Git is already installed. Open a terminal (Command Prompt, PowerShell or Windows Terminal on Windows; Terminal on Linux) and run:

git --version

If you see something like git version 2.47.1, Git is installed; you can still follow this lesson to update it. If you see “command not found” or “‘git’ is not recognized”, install it now.

On a Mac? Follow Install Git on macOS instead, then continue with Configure Git.


🪟 Install Git on Windows (Installer)

  1. Go to git-scm.com and click Download for Windows. Choose the 64-bit Git for Windows Setup installer.
  2. Run the installer. Most default options are fine; these are the important screens:
Installer screenRecommended choiceWhy
Choosing the default editorVisual Studio Code (or Notepad++)The default, Vim, is hard for beginners
Adjusting the name of the initial branchOverride… and use “main”GitHub uses main as the default branch name
Adjusting your PATH environmentGit from the command line and also from 3rd-party softwareLets you use git in PowerShell, CMD and VS Code
SSH executableUse bundled OpenSSHWorks with the SSH lesson
Line ending conversionsCheckout Windows-style, commit Unix-styleAvoids line-ending problems with teammates on macOS and Linux
Terminal emulatorUse MinTTYBetter Git Bash terminal
Default behaviour of git pullFast-forward or merge (default)Explained in fetch vs pull
Credential helperGit Credential ManagerSigns in to GitHub securely in the browser
  1. Click Install, then Finish.
  2. Open a new terminal and verify:
git --version

⚠️ Common mistake: If git is still “not recognized”, close every terminal and VS Code window and open them again so they pick up the updated PATH. If it still fails, re-run the installer and check the PATH option above.

What did the installer add?

  • Git Bash: a Linux-style terminal for Windows. Commands in this course such as ls, cat and touch work there. See Essential Terminal Commands for Git.
  • Git GUI: a simple graphical tool (rarely needed).
  • Git Credential Manager: stores your GitHub login securely.

⚡ Install Git on Windows with winget

Prefer the command line? Windows 10 and 11 include the winget package manager:

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

Close and reopen the terminal, then run git --version. winget uses the installer defaults, so set the default branch name and editor in the next lesson.


🐧 Install Git on Linux

Use your distribution’s package manager:

# Ubuntu, Debian, Linux Mint
sudo apt update
sudo apt install git

# Fedora
sudo dnf install git

# CentOS Stream, RHEL, Rocky, AlmaLinux
sudo dnf install git

# Arch Linux, Manjaro
sudo pacman -S git

# openSUSE
sudo zypper install git

Verify:

git --version

📝 Note: Distribution packages can be a few versions behind the latest Git release. That is fine for this course. On Ubuntu you can get newer versions from the official Git PPA: sudo add-apt-repository ppa:git-core/ppa, then sudo apt update && sudo apt install git.


🔄 Updating Git Later

PlatformUpdate command
Windows (Git for Windows 2.16.1 or newer)git update-git-for-windows
Windows (winget)winget upgrade --id Git.Git
Ubuntu or Debiansudo apt update && sudo apt install --only-upgrade git
Fedorasudo dnf upgrade git

🐞 Troubleshooting

ProblemFix
'git' is not recognized on WindowsReopen the terminal; re-run the installer with the PATH option “from the command line and also from 3rd-party software”
VS Code does not find GitRestart VS Code; check Settings, git.path
Permission denied on LinuxUse sudo for the install command
Old version on LinuxUse the distribution’s backports or the Git PPA (Ubuntu)
Corporate proxy blocks downloadsAsk IT for the approved installer, or download on another network

📝 Assignment

  1. Install Git on your computer and paste the output of git --version into a notes file.
  2. On Windows, open Git Bash and run pwd, ls and cd ~. What does each command show?
  3. Open VS Code, open any folder, and check that the Source Control panel (Ctrl + Shift + G) no longer says Git is missing.
  4. Write down which line-ending option you chose during installation, and why it matters for teams.

❓ FAQ

🤔 How do I install Git on Windows?

Download Git for Windows from git-scm.com, run the installer (choose VS Code as editor, “main” as the default branch and the recommended PATH option), then check git --version in a new terminal. Or run winget install --id Git.Git -e --source winget.

🤔 How do I install Git on Ubuntu?

Run sudo apt update and sudo apt install git, then verify with git --version.

🤔 How do I check if Git is installed?

Open a terminal and run git --version. If it prints a version number, Git is installed.

🤔 What is Git Bash?

A terminal installed with Git for Windows that supports Linux-style commands such as ls, cat and rm, which makes following Git tutorials easier on Windows.

🤔 Do I need a GitHub account to install Git?

No. Git works without an account. You will create a GitHub account in Lesson 6 to share your repositories online.


🎯 Next Steps

🎬 Learn Git and GitHub step by step: watch the series on YouTube!

Subscribe to SqaToolsByDY • Practice on sqatools.in

4 thoughts on “How to Install Git on Windows and Linux (Step by Step)”

Leave a Comment