Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

Git Tutorial

Git HOME Git Intro Git Install Git Config Git Get Started Git New Files Git Staging Git Commit Git Remove and Move Git Tagging Git Stash Git History Git Diff Git Blame Git Help Git Branch Git Merge Git Workflow Git Best Practices

Git and GitHub

GitHub Get Started Git What is SSH? GitHub Add SSH GitHub Set Remote GitHub Edit Code Pull from GitHub Push to GitHub GitHub Branch Pull Branch from GitHub Push Branch to GitHub GitHub Flow GitHub Pages Git GUI Clients

Git Contribute

GitHub Fork Git Clone from GitHub GitHub Send Pull Request

Git Undo

Git Revert Git Reset Git Clean Git Amend Git Rebase Git Reflog Git Recovery

Git Advanced

Git .gitignore Git .gitattributes Git Large File Storage (LFS) Git Signing Commits/Tags Git Cherrypick & Patch Git Bisect Git Merge Conflicts Git CI/CD Git Hooks Git Submodules Git Worktree Git Remote Advanced

Git and Bitbucket

Bitbucket Get Started Bitbucket Add SSH Bitbucket Set Remote Bitbucket Edit Code Bitbucket Branch Bitbucket Pages Bitbucket Fork Git Clone from Bitbucket Bitbucket Send Pull Request

Git and GitLab

GitLab Get Started GitLab Add SSH GitLab Set Remote GitLab Edit Code GitLab Branch GitLab Pages GitLab Fork Git Clone from GitLab GitLab Send Pull Request

Git Cert

Git Certificate

Git Reference

Git Glossary

Git Exercises

Git Terminal Git Exercises Git Challenges Git Quiz Git Syllabus Git Study Plan

Git Install


Share

How to Install Git

You can download Git for free from git-scm.com.

  • Windows: Download and run the installer.
    Click "Next" to accept the recommended settings.
    This will install Git and Git Bash.
  • macOS: If you use Homebrew, open Terminal and type brew install git.
    Or, download the .dmg file and drag Git to your Applications folder.
  • Linux: Open your terminal and use your package manager.
    For example, on Ubuntu: sudo apt-get install git

After installation, you will be able to use Git from your terminal or command prompt.

Tip for Beginners: Installing Git is safe and you can always uninstall it later if you want.


Git Bash

Git Bash is a terminal for Windows that lets you use Git commands.

Look at our Bash Tutorial to learn more about Bash.

After installing Git, you can find Git Bash in your Start menu.

You can use Git Bash just like the Command Prompt, but with extra Unix commands (like ls and pwd).

Example: Open Git Bash

Git Bash

Click Start, type "Git Bash", and open the app.

Example: First Command in Git Bash

ls
Desktop  Documents  Downloads  Pictures

This command lists the files in your current folder.



Verifying Your Installation

After installing, check that Git works by opening your terminal (or Git Bash on Windows) and running:

Example: Check Git Version

git --version
git version 2.43.0.windows.1
Try it Yourself »

If Git is installed, you will see something like git version X.Y.Z.

If you see an error, try closing and reopening your terminal, or check that Git is in your PATH.


Default Editor

During installation, Git asks you to pick a default text editor.

This is the program that will open when you need to write messages (like for commits).

Example: Set VS Code as Default Editor

git config --global core.editor "code --wait"
Try it Yourself »

If you're not sure, just pick the default (Notepad on Windows). You can always change this later.

Example: Set Notepad as Default Editor

git config --global core.editor "notepad"
Try it Yourself »

PATH Environment

Choosing to add Git to your PATH means you can use Git commands in any terminal window.

We recommend doing this during installation.

If you skip this, you'll only be able to use Git in Git Bash (on Windows) or Terminal (on macOS and Linux).

Example: Check if Git is in PATH

git --version
git version 2.43.0.windows.1
Try it Yourself »

If you see an error, you need to add Git to your PATH.


How to Add Git to PATH after Installation

  • Windows:
    1. If you missed the option during installation, search for "Environment Variables" in the Start menu and open it.
    2. Click "Environment Variables..." and find the "Path" variable under "System variables".
    3. Click "Edit", then "New", and add the path to your Git bin and cmd folders
      (e.g., C:\Program Files\Git\bin and C:\Program Files\Git\cmd).
    4. Click OK to save. Restart your terminal.
  • macOS:
    1. If you installed with Homebrew, your PATH is usually set automatically.
    2. If not, open Terminal and add this line to your ~/.zshrc or ~/.bash_profile:
    3. export PATH="/usr/local/bin:$PATH"
    4. Save the file and run source ~/.zshrc or source ~/.bash_profile.
  • Linux:
    1. Most package managers add Git to PATH automatically.
    2. If not, add this line to your ~/.bashrc or ~/.profile:
    3. export PATH="/usr/bin:$PATH"
    4. Save the file and run source ~/.bashrc or source ~/.profile.

After adding Git to your PATH, open a new terminal window and run git --version to check that it works everywhere.


Line Endings

Git can convert line endings in text files.

On Windows, it's usually best to select "Checkout Windows-style, commit Unix-style line endings".

This helps prevent problems when you share code with people using different operating systems.


Updating or Uninstalling Git

  • Update: Download and run the latest installer, or use your package manager
    (e.g., brew upgrade git or sudo apt-get upgrade git).
    It's a good idea to keep Git up to date for the latest features and security fixes.
  • Uninstall: Use "Add or Remove Programs" on Windows, or your package manager on Mac/Linux.

Troubleshooting Git Installation

If you run into problems installing or running Git, don't worry!

Here are solutions to some of the most common issues.

Tip: If something doesn't work right away, try closing and reopening your terminal, or restarting your computer.

Common Installation Issues

  • "git is not recognized as an internal or external command"
    Solution: Git is not in your system's PATH. Make sure you installed Git and restart your terminal.
    If needed, add Git's bin folder (usually C:\Program Files\Git\bin) to your PATH.
    If it still doesn't work, try restarting your computer.
  • Permission errors ("Permission denied")
    Solution: On Windows, run Git Bash or your terminal as administrator.
    On macOS/Linux, use sudo if necessary.
  • SSL or HTTPS errors when cloning/pushing
    Solution: Check your internet connection.
    Make sure your Git version is up to date.
  • Wrong version of Git
    Solution: Check your installed version with git --version.
    Download the latest version from git-scm.com if needed.



Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.