Master Code
On The Go

Learn. Practice. Build.

How-To Guide

How to Install Git

Git is the version control system every developer uses. Install it once, use it forever. Here's the complete setup on Windows, Mac, or Linux.

📚 What is Git?

Git is a version control system — software that tracks every change you make to your code. It's used by virtually every professional developer and team in the world.

Git lets you:

💡 Git is the tool. GitHub is a website that hosts Git repositories. You install Git on your computer, then push to GitHub.

📋 What You'll Need

✅ Git is completely free and open source.

1

Download Git

Go to the official website:

👉 git-scm.com/downloads

;

Choose your operating system:

  • Windows: Click "Windows" → the installer downloads automatically
  • Mac: Click "macOS" → you can install via Homebrew or download the installer
  • Linux: Click "Linux" → use the recommended command for your distro

💡 Mac users: You might already have Git installed. Open Terminal and run git --version. If it says a version number, you already have it. If it asks you to install developer tools, click "Install" — that installs Git automatically.

2

Run the Installer

Windows:

  1. Open the downloaded .exe file
  2. Click "Next" through the welcome screen
  3. Accept the license
  4. Keep the default install location
  5. Important step: On the "Choosing the default editor" screen, choose Visual Studio Code if you have it installed
  6. On "Adjusting your PATH environment", keep "Git from the command line and also from 3rd-party software" selected
  7. On the "HTTPS transport backend" screen, keep "Use the OpenSSL library"
  8. On "Configuring the line ending conversions", keep "Checkout Windows-style, commit Unix-style"
  9. Keep the remaining defaults
  10. Click "Install" → "Finish"

Mac (via Homebrew):

brew install git

Or use the official installer from git-scm.com.

Linux (Ubuntu/Debian):

sudo apt update
sudo apt install git

For Fedora/RHEL:

sudo dnf install git
3

Verify the Installation

Open a fresh terminal window (important — old windows won't see PATH changes):

git --version

You should see something like:

git version 2.43.0

If you see a version number, Git is installed.

Need help opening a terminal? See our Command Line Basics guide.

4

Configure Your Identity (One-Time Setup)

Before your first commit, Git needs to know who you are. Every commit you make includes a name and email.

Set your name:

git config --global user.name "Your Name"

Set your email (use the same email you'll use for GitHub):

git config --global user.email "you@example.com"

Verify your settings:

git config --list

You should see your name and email listed.

💡 What does --global mean? It sets the config for every Git repository on your computer. You can also set values per-project by omitting --global.

5

Your First Commit

Let's create a test project and make your first commit.

1. Create a folder and enter it:

mkdir git-test
cd git-test

2. Initialize a Git repository:

git init

You should see: Initialized empty Git repository in ...

3. Create a test file:

# Mac/Linux
touch hello.txt

# Windows
type nul > hello.txt

4. Check the status:

git status

You'll see hello.txt listed as "untracked".

5. Stage the file:

git add hello.txt

6. Commit it:

git commit -m "First commit"

You should see something like:

[main (root-commit) a1b2c3d] First commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 hello.txt

🎉 Congratulations — you've made your first Git commit!

🛠️ The Essential Git Commands

These are the 7 commands you'll use almost every day:

git status

See what files have changed since your last commit.

git add filename.txt

Stage a file to be included in the next commit. Use git add . to stage everything.

git commit -m "message"

Save a snapshot with a descriptive message.

git log

See the history of commits. Add --oneline for a compact view.

git diff

See exactly what changed in unstaged files.

git branch

List all branches. git branch name creates a new one.

git pull / git push

Get the latest changes from a remote (GitHub) or send your commits to it.

🔧 Common Errors (and Fixes)

❌ 'git' is not recognized as an internal or external command

Git isn't on your PATH. Fixes:

  1. Close and reopen your terminal
  2. Reboot your computer if that doesn't work
  3. On Windows, reinstall Git and ensure it uses the default install location

❌ "Please tell me who you are" error on first commit

You skipped Step 4. Run:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

❌ "fatal: not a git repository"

You're not inside a Git repo folder. Either cd into the correct folder, or run git init to create a new repository.

❌ "nothing to commit, working tree clean"

You haven't made any changes since your last commit, or you forgot to git add your changes first.

❌ Permission denied when using SSH to GitHub

You need to add an SSH key to GitHub. For your first push, use HTTPS instead of SSH — simpler for beginners:

git remote set-url origin https://github.com/yourusername/repo.git
;

❌ Accidentally committed sensitive data (passwords, API keys)

Rotate the exposed keys immediately. Then use .gitignore to prevent future accidents:

# In .gitignore
.env
secrets.txt
node_modules/

🎯 What's Next?

Git is installed. Next, put your code on the internet for free.

← All How-To Guides