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:
- Save snapshots of your code at any point (called "commits")
- Roll back to a previous version if you break something
- Work on branches without affecting the main code
- Collaborate with other developers without overwriting work
- Publish your code to GitHub, GitLab, or Bitbucket
💡 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
- A computer running Windows 10/11, macOS 11+, or Linux
- An internet connection
- About 50 MB of free disk space
- Basic familiarity with the terminal — see our Command Line guide if you're new
✅ Git is completely free and open source.
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.
Run the Installer
Windows:
- Open the downloaded
.exefile - Click "Next" through the welcome screen
- Accept the license
- Keep the default install location
- Important step: On the "Choosing the default editor" screen, choose Visual Studio Code if you have it installed
- On "Adjusting your PATH environment", keep "Git from the command line and also from 3rd-party software" selected
- On the "HTTPS transport backend" screen, keep "Use the OpenSSL library"
- On "Configuring the line ending conversions", keep "Checkout Windows-style, commit Unix-style"
- Keep the remaining defaults
- 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
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.
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.
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:
- Close and reopen your terminal
- Reboot your computer if that doesn't work
- 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.