Installing Git sets up the command-line interface (git) and core tools across Windows, macOS, or Linux environments.
You can download Git for free from git-scm.com.
brew install git.sudo apt-get install gitAfter 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 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).
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.
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
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.
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"
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"
Choosing to add Git to your PATH means you can use Git commands in any terminal window.
This is highly recommended for most users to do 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
If you see an error, you need to add Git to your PATH.
Windows:
bin and cmd foldersC:\Program Files\Git\bin and C:\Program Files\Git\cmd).macOS:
If you installed with Homebrew, your PATH is usually set automatically.
If not, open Terminal and add this line to your ~/.zshrc or ~/.bash_profile:
export PATH="/usr/local/bin:$PATH"
Save the file and run source ~/.zshrc or source ~/.bash_profile.
Linux:
Most package managers add Git to PATH automatically.
If not, add this line to your ~/.bashrc or ~/.profile:
export PATH="/usr/bin:$PATH"
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.
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.
brew upgrade git or sudo apt-get upgrade git).If you run into problems installing or Practice 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.
bin folder (usually C:\Program Files\Git\bin) to your PATH.sudo if necessary.git --version.Execute the following terminal commands to work with this concept in your workspace:
# Verify Git binary location on Linux/macOS
which git
# Check installed version on Windows (Command Prompt/PowerShell)
git --version
Fix CORS bug rather than Fixed CORS bug).git diff to review unstaged modifications before adding files to the index.git switch -c <branch-name> to preserve edits.git restore --staged <filename> to remove the file from the index without altering your local workspace copy.Open your terminal in a test project directory, execute git status, and verify your current working tree state. Practice running git log --oneline to review commit history.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With