Skip to content
RU
← All articles

How to Install Git on Windows, Mac and Linux: Step by Step

A laptop with a terminal showing a colorful Git graph of branches and commits

How to install Git on Windows: download the Git for Windows installer from git-scm.com (or run winget install --id Git.Git -e --source winget), accept the recommended options, then open a new terminal and run git --version. On macOS use xcode-select --install or Homebrew; on Linux use your distribution's package manager.

Do I need to install Git on Windows?

Yes, if you want to use Git from the command line, from an editor like VS Code or from an IDE. Windows does not ship with Git, and VS Code does not bundle it either — the editor looks for a Git that is already installed on the system. The only case where you can skip it is GitHub Desktop, which carries its own copy of Git for its own use; that copy is not available to your terminal.

A quick refresher on what you are installing. Git is a version control system: it records every saved state of a project, who made each change and why, and lets you go back to any of them. A repository is a project folder with a hidden .git directory that holds the whole history. A commit is one saved snapshot with an author, a date and a message. A branch is a movable pointer to a line of commits, so you can build a feature without touching the working version.

Is Git for Windows the same as GitHub?

No. Git for Windows is the Windows build of Git itself — a free, open source program (GPLv2) maintained by the Git for Windows project and linked from the official download page. GitHub is a hosting service for Git repositories owned by Microsoft. You can use Git with GitHub, GitLab, Bitbucket, a self-hosted server or no server at all. GitHub Desktop is yet another thing: a graphical client made by GitHub.

NameWhat it isDo you need it?
GitThe version control programYes, this is the core tool
Git for WindowsThe Windows build of Git, plus Git Bash, Git GUI and Git Credential ManagerYes, on Windows
Git BashA bash terminal shipped inside Git for WindowsOptional; comes with the installer
GitHubA website that hosts Git repositoriesOnly if your project lives there
GitHub DesktopA graphical Git client from GitHubOptional; many people never use it

How to install Git on Windows step by step

Go to git-scm.com/downloads, pick Windows and download the 64-bit setup. Download it only from there or from gitforwindows.org; repackaged installers on download portals add nothing and are a common way to ship malware. Most screens can be left at their defaults. These are the ones that actually matter (wording and order shift a little between releases):

  1. Select Destination Location — the default is C:\Program Files\Git. Keep it unless you have a reason not to.
  2. Select Components — the Explorer integration adds "Open Git Bash here" to the right-click menu, which is handy.
  3. Choosing the default editor used by Git — the default is Vim. If you do not use Vim, pick Visual Studio Code or Notepad++. Otherwise your first git commit without -m drops you into Vim (to get out: Esc, then :wq, then Enter).
  4. Adjusting the name of the initial branch — choose to override the default and enter main, matching GitHub and GitLab.
  5. Adjusting your PATH environment — keep the recommended option that makes Git available from the command line and third-party software. That is what lets cmd, PowerShell, VS Code and other tools find git.
  6. Choosing the SSH executable — the bundled OpenSSH works for almost everyone.
  7. Configuring the line ending conversions — the Windows default checks files out with CRLF line endings and commits them with LF. That is the right choice for projects shared with macOS and Linux users.
  8. Configuring the terminal emulator — MinTTY behaves better than the old console window for copying, pasting and resizing.
  9. Choose a credential helper — keep Git Credential Manager. It signs you in to GitHub or GitLab through the browser once and stores the credentials securely.

Prefer the command line? Open PowerShell or Command Prompt and use the Windows Package Manager:

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

Close and reopen every terminal afterwards — the updated PATH only applies to new sessions. For a refresher on cmd itself, see our Windows command line guide.

How do I check if Git is installed?

git --version

A line like git version 2.x.x.windows.1 means you are done. In Command Prompt the failure message is "'git' is not recognized as an internal or external command, operable program or batch file"; in PowerShell it is "The term 'git' is not recognized". Both mean Git is missing or not on PATH.

Where is Git installed in Windows?

By default, in C:\Program Files\Git. The git.exe that your terminal runs lives in the cmd subfolder, and Git Bash and the Unix tools live under usr\bin and bin. To see exactly which copy is being used:

where git            :: Command Prompt
Get-Command git      # PowerShell
which git            # Git Bash, macOS, Linux

If where git prints two paths, the first one wins. That is how an old portable copy or a leftover install can shadow the version you just installed. To upgrade Git for Windows, run the newer installer over the old one, or use winget upgrade --id Git.Git.

How to install Git on Mac

The quickest route is Apple's Command Line Tools:

xcode-select --install

Often you do not even need that: type git --version in Terminal, and if Git is missing, macOS offers to install the developer tools for you. If you use Homebrew, it usually gives you a newer version that updates with your other packages:

brew install git
brew upgrade git

If git --version still shows Apple's version after a Homebrew install, /usr/bin/git comes first on your PATH. Run which -a git: the Homebrew path (/opt/homebrew/bin/git on Apple Silicon, /usr/local/bin/git on Intel) should be listed first.

How to install Git on Linux

Use the package manager. There is nothing to download by hand:

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

# Fedora, RHEL, AlmaLinux, Rocky
sudo dnf install git

# Arch Linux
sudo pacman -S git

# openSUSE
sudo zypper install git

Long-term-support releases may ship an older Git. That is fine for most work; if you need something newer, the options for each distribution are listed on git-scm.com's Linux page.

How do I set up Git for the first time?

Every commit is signed with a name and an email. Without them, git commit stops with "Please tell me who you are". Settings with --global go into ~/.gitconfig and apply to all your repositories:

git config --global user.name "Jane Doe"
git config --global user.email "jane@example.com"
git config --global init.defaultBranch main
git config --global core.editor "code --wait"

The last line makes VS Code the commit message editor; it only works if the code command is on your PATH. To review everything and see which file each value comes from:

git config --list --show-origin

Run the same git config user.email command inside a project folder without --global to use a different address for that repository only. Your commit email is visible to anyone who can read the repository; GitHub offers a private noreply address for public work.

Your first Git commands

git clone https://github.com/user/project.git   # copy a repository with its history
cd project
git status                                      # what changed
git add .                                       # stage changes
git commit -m "Fix header layout"               # save a snapshot
git push                                        # send commits to the server
git pull                                        # fetch and merge others' changes

Starting from scratch instead of cloning? Run git init in the project folder. Need a single branch only? git clone --branch release --single-branch URL. Need just the latest files and no history? Add --depth 1.

Signing in to GitHub

GitHub does not accept your account password for Git operations over HTTPS. On Windows, Git Credential Manager handles this with a browser sign-in on your first push. On servers, SSH keys are simpler: add your public key under GitHub's Settings, then SSH and GPG keys, and clone with git@github.com:user/project.git. Our SSH key authentication guide covers generating the key and file permissions. Test the connection with ssh -T git@github.com.

Using Git in VS Code

VS Code uses the system Git. If the Source Control view (Ctrl+Shift+G) says Git was not found, install Git as described above and restart the editor; a non-standard location can be set in the git.path setting. See the VS Code guide for the rest.

Deploying with git pull? Check that .git is not public

Cloning a repository straight into the web root and running git pull to deploy is quick, but it leaves a .git directory next to your site files. If the web server serves it, anyone can download /.git/config, /.git/HEAD and the object files and rebuild your source code — including anything that was ever committed, such as an old database password or API key. Deleting a file in a later commit does not remove it from history.

Check your own site:

curl -sI https://your-site.com/.git/HEAD

You want 403 Forbidden or 404 Not Found. If you get 200, look at the body with curl -s https://your-site.com/.git/HEAD: a line like ref: refs/heads/main means the directory is exposed. A normal HTML page usually means the CMS answers every path with the home page, which is not a leak — but check /.git/config the same way.

In nginx, block it inside the server block, above other regex locations (nginx checks them in order), then run sudo nginx -t && sudo systemctl reload nginx (our nginx configuration guide explains where the config files live):

location ~ /\.git {
    deny all;
}

In Apache, add this to the virtual host config or to .htaccess in the site root:

RedirectMatch 404 /\.git

Better still, keep .git out of the served folder: point the document root at a subfolder such as public/, or deploy build artifacts from CI without the history. If the directory was ever exposed, rotate every secret that has ever been in the repository.

How to check your site

  • Run the website security check. After the main scan it offers a "deep exposure check" that looks for open .git, .env, phpinfo and other sensitive files — about 30 paths, no sign-up required.
  • After changing the server config, confirm the site still answers normally with the HTTP header checker.

Frequently asked questions

Is Git free?

Yes. Git is open source under GPLv2, and the official installers need no account or license key.

Do I need Git Bash?

No. It is installed with Git for Windows, but git works the same in Command Prompt and PowerShell. Git Bash helps when you follow tutorials written for Linux or macOS.

Can I install Git without admin rights?

Yes. The download page offers a portable version for Windows that runs from an unpacked folder without writing to system locations.

How do I update Git?

On Windows, run the latest installer or winget upgrade --id Git.Git. On macOS with Homebrew, brew upgrade git. On Linux, update it through your package manager with the rest of the system.

Is it safe to keep .git on a production server?

Only if the web server refuses to serve it. curl -sI https://your-site.com/.git/HEAD should return 403 or 404.

Check your website right now

Check your domain →
More articles: Tools
Tools
Batch URL Checking: Automating Website Monitoring
11.03.2026 · 542 views
Tools
Wayback Machine Guide: Find, Save and Remove Archived Pages
23.09.2026 · 306 views
Tools
Website Builders 2026: What You Give Up and How to Migrate
21.07.2026 · 213 views
Tools
What Is an MCP Server and Why It Matters
15.06.2026 · 194 views